What's wrong with this code?
I am getting that name IsNumeric does not exist in current contex. I found many examples like these online and non of them are working. So, how can I called this method properly.
As far as I know, it should be static in order to call it directly: bool isNumeric = IsNumeric("123abc456").
If method is not static, what do I do? Thanks.
I am getting that name IsNumeric does not exist in current contex. I found many examples like these online and non of them are working. So, how can I called this method properly.
As far as I know, it should be static in order to call it directly: bool isNumeric = IsNumeric("123abc456").
If method is not static, what do I do? Thanks.
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Test
{
class Program
{
public bool IsNumeric_Regex(object num)
{
Regex r = new Regex(@"(^[-+]?\d+(,?\d*)*\.?\d*([Ee][-+]\d*)?$)|(^[-+]?\d?(,?\d*)*\.\d+([Ee][-+]\d*)?$)");
return r.Match(num.ToString()).Success;
}
static void Main(string[] args)
{
[b]bool isNumeric = IsNumeric("123abc456");[/b]
Console.Write("Press Enter to Exit!");
Console.Read();
}
}
}
[code]