|
C# has no built-in equivalent to VB's IsNumeric function. In
fact, there is no single method call in all of the .NET Framework
that simulates IsNumeric. The best alternative in C# is to
write your own method similar to the following:
internal static bool IsNumeric(object ObjectToTest)
{
if (ObjectToTest == null)
{
return false;
}
else
{
double OutValue;
return
double.TryParse(ObjectToTest.ToString().Trim(),
System.Globalization.NumberStyles.Any,
System.Globalization.CultureInfo.CurrentCulture,
out OutValue);
}
}
If you need to convert from
VB to C#
and you are depending on the results being reliable and accurate,
then you will want to have
Instant C#, the best
VB to C# converter, at your fingertips.
|