网络系统搭建,站长工具seo综合查询网,云主机是什么,广州专业网站建设价格c#统计字符串中数字字符的个数
题目描述 假设有一个GetNumber方法#xff08;参数为字符串strSource#xff09;#xff0c;编写一个静态方法可以用来统计字符串strSource中数字字符的个数。 输入 输入一个字符串strSource输出 strSource字符串中数字字符的个数样例输入
s…c#统计字符串中数字字符的个数
题目描述 假设有一个GetNumber方法参数为字符串strSource编写一个静态方法可以用来统计字符串strSource中数字字符的个数。 输入
输入一个字符串strSource输出
strSource字符串中数字字符的个数样例输入
stylecolor:#333333asffkl8asjkfjklas3jdf9lkj!
样例输出
3
using System;
using System.Collections;namespace sample
{class Program{static int GetNumber(string strSource){int num0;for (int i 0; i strSource.Length; i){if(strSource[i] 0 strSource[i] 9){num;}}return num;}static void Main(string[] args){string strSource Console.ReadLine();Console.WriteLine(GetNumber(strSource));}}
}