c#.net
public static bool IsNumeric(string txt) { string str = txt.Trim(); if (!Regex.IsMatch(txt.Trim(), "^([0-9,-])")) { return false; } return true; }