I have a char in c#:
char foo = \'2\';
Now I want to get the 2 into an int. I find that Convert.ToInt32 returns the actual decimal value o
Has anyone considered using int.Parse() and int.TryParse() like this
int.Parse()
int.TryParse()
int bar = int.Parse(foo.ToString());
Even better like this
int bar; if (!int.TryParse(foo.ToString(), out bar)) { //Do something to correct the problem }
It's a lot safer and less error prone