There are several different ways to code a custom function to do the same in C#. Here is one way:
using System;
using System.Text;
using System.Text.RegularExpressions;
public static bool IsNumeric(string psInputString)
{
return Regex.IsMatch(psInputString, "^[0-9]+$");
}
And here is how Microsoft recommends it on THIS page:
static bool IsNumeric(object Expression)
{
bool isNum;
double retNum;
isNum = Double.TryParse(
Convert.ToString(Expression),
System.Globalization.NumberStyles.Any,
System.Globalization.NumberFormatInfo.InvariantInfo,
out retNum );
return isNum;
}
Either way you will get the same result.
Pete Soheil
DigiOz Multimedia
www.digioz.com
No comments:
Post a Comment