you can use Conver.ToInt32(string) and Int32.Parse(string) or direct int.Parse(string)
you can also use int32.tryparse (string, out int result) or: int.tryparse (string, out int result) to convert.
the return value of p>TryParse is a bool value, indicating whether the conversion is successful. After the conversion is successful, the second parameter is the value you have successfully converted:
For example,
int result;
if (int 32. try parse ("2", out result)) {
//conversion succeeded
} else {
// conversion failed
}