Sunday, August 2, 2009

What is the easiest way to determine if a string is a number in c#?

Convert.ToInt32()


will convert char's and strings





I am trying to get


Int32.TryParse(Console.ReadLine(), System.Globalization.NumberStyles.Intege... IFormatProvider, out searchZip);





..to work but wtf is an IFormat provider and is there a simple version of one that I can use or make?





...what is the simplest way to do this?





for my purposes 99999 is a number and 99,999 is not a number. wererewoiy definately is not a number.

What is the easiest way to determine if a string is a number in c#?
public static bool IsNumeric(object Expression)


{


bool isNum;


double retNum;


isNum = Double.TryParse(Convert.ToString(Express... System.Globalization.NumberStyles.Any,Sy... out retNum );


return isNum;


}





Try this


No comments:

Post a Comment