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

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!
 
M

Mickey Williams

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top