using System;class MyTrim{
static void Main(){
string s = " HelloÖÐÎÄ ";
Console.WriteLine(ChineseCount(s));
}
static bool IsChinese(string str)
{
return (int)str[0] >= 0x4E00 && (int)str[0] <= 0x9FA5;
}
static int ChineseCount(string str){
int count = 0;
foreach(char c in str)
if(IsChinese(c.ToString()))
count++;
return count;
}
}
static void Main(){
string s = " HelloÖÐÎÄ ";
Console.WriteLine(ChineseCount(s));
}
static bool IsChinese(string str)
{
return (int)str[0] >= 0x4E00 && (int)str[0] <= 0x9FA5;
}
static int ChineseCount(string str){
int count = 0;
foreach(char c in str)
if(IsChinese(c.ToString()))
count++;
return count;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货