用Linq来统计指定字符的数量
using System;
using System.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string m = "1@3@4@5@6@7@8@!23*35*67*34*56*78*45*68*89*45*67*09*46*78*90*67*87*78*89*34*67*";
Console.WriteLine(m);
Console.Write("输入要搜索的字符:");
char s = Convert.ToChar(Console.ReadLine());
var qry = from c in m
where
c == s
select c;
Console.WriteLine("
字符串中{0}的数量为{1}", s, qry.Count());
}
}
}