public static bool IsInteger(this string sItem) { Regex notIntPattern = new Regex("[^0-9-]"); Regex intPattern = new Regex("^-[0-9]+$|^[0-9]+$"); return !notIntPattern.IsMatch(sItem) && intPattern.IsMatch(sItem); }