您的位置:首页 > 其它

判断输入是否为汉字的方法

2011-12-21 11:34 351 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 判断是否为汉字
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入:");
IsChina(Console.ReadLine());
Console.ReadLine();
}
public static  bool IsChina(string CString)
{
bool BoolValue=false;
for (int i=0; i<CString.Length; i++)
{
if(Convert.ToInt32(Convert.ToChar(CString.Substring(i,1)))<Convert.ToInt32(Convert.ToChar(128)))
{
BoolValue = false;
Console.WriteLine("非汉字");
}
else
{
BoolValue = true;
Console.WriteLine("汉字");
}
}
return BoolValue;
}
}
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: