Use Convert.ToInt32 method to convert text to an integer.
Firstly, set a string.
string str = "12";
Now, use the Convert.ToInt32() method the above string to number.
Convert.ToInt32(str);
Let us see the complete example.
Example
using System;
class Program {
static void Main() {
string str = "12";
Console.WriteLine("String: "+str);
int n = Convert.ToInt32(str);
Console.WriteLine("Number: "+n);
}
}Output
String: 12 Number: 12