Int32.Parse -vs-Convert.ToInt32(#,base)

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

I'm a self-learning C# newbie So this may be a dumb question to some
of you, but I'll ask it anyway :)


Is there more reason to use one over the other?
Both Int32.Parse and Convert.ToInt32(#,base) work equally well in the
snippit below.

Console.Write("what is your age?:");
age = Console.ReadLine();
try
{ addage=System.Int32.Parse(age);
}
//addage=Convert.ToInt32(age,10);}




Tony!
 
Convert.ToInt32(string) calls Int32.Parse(string). However, if you use
Int32.Parse (or the equivalent int.Parse), you can specify globalization and
formatting used when parsing.
 
Back
Top