可以使用正则表达式来实现。 string test ; int count = Regex.Matches(test, @"\d").Count; return count; 其中,count 为字符串中数字的个数。