Check out example codes for "how to convert string to int in c#". It will help you in understanding the concepts better.

Code Example 1

string a = ("2");
int b = Convert.ToInt16(a)

Code Example 2

int x = Int32.Parse(TextBoxD1.Text);

Code Example 3

int i = 0;

// bool to Int32
bool b = true;
i = Convert.ToInt32(b);

// byte to Int32
byte bt = 3;
i = Convert.ToInt32(bt);

// char to Int32
char c = 'A';
i = Convert.ToInt32(c);

// DateTime to Int32
DateTime dt = DateTime.Now;
i = Convert.ToInt32(dt);

// Decimal to Int32
decimal d = 25.678m;
i = Convert.ToInt32(d);

// double to Int32
double db = 0.007234;
i = Convert.ToInt32(db);

Code Example 4

int x = 0;

Int32.TryParse(TextBoxD1.Text, out x);

Code Example 5

.Net str to Int

Code Example 6

string userInput = Console.ReadLine();
int convert;
Int32.TryParse(userInput, out convert);  // Converting String to int

Learn ReactJs, React Native from akashmittal.com