Use the int.TryParse method.
string x = "42";
if(int.TryParse(x, out int value))
// Do something
If it successfully parses it will return true, and the out result will have its value as an integer.
Use the int.TryParse method.
string x = "42";
if(int.TryParse(x, out int value))
// Do something
If it successfully parses it will return true, and the out result will have its value as an integer.