タイトル説明
GetNumberメソッド(パラメーターは文字列strSource)があり、静的メソッドを記述して、文字列strSourceの数字の数を数えることができるとします。
入る
文字列strSourceを入力します
出力
strSource文字列の数字の数
サンプル入力
asffkl8asjkfjklas3jdf9lkj!
サンプル出力
3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string strSource = Console.ReadLine();
int count=0;
for(int i=0;i<strSource.Length;i++)
{
if(strSource[i]>='0'&&strSource[i]<='9')
{
count++;
}
}
Console.WriteLine(count);
}
}
}