There are several ways to cast,
For e.g
string s = "123";
int byCasting = (int)s;
int byParsing = int.Parse(s);
int result;
int.TryParse(s,out result);
int byConverting = Convert.ToInt32(s);
But among of all I think the
TryParse
is best.
Please
vote and
Accept Answer if it Helped.