string input = Console.ReadLine(); bool isMatch = Regex.IsMatch(input, @"^\d*$"); Console.WriteLine(isMatch);
\d 表示数字
*表示0个,一个,多个
IsMatch方法,表示是否匹配