string a = "a123"; if (a != null && Regex.IsMatch(a, @"^\d+$")) { Console.WriteLine("数字"); } else { Console.WriteLine("不是数字"); } Console.ReadLine();