判断是否是中文英文字符串

Posted goldenellipsis

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了判断是否是中文英文字符串相关的知识,希望对你有一定的参考价值。

技术图片
 1 using System;
 2 
 3 public class Example
 4 {
 5    public static void Main()
 6    {
 7         bool isChinese = false;
 8         string CString = "a.有能力的;出色的";
 9         for (int i = 0; i < CString.Length; i++)
10         {
11             if (Convert.ToInt32(Convert.ToChar(CString.Substring(i, 1)))< Convert.ToInt32(Convert.ToChar(128)))
12             {
13                 isChinese = false;
14             }
15             else
16             {
17                 isChinese = true;
18             }
19         }
20         Console.WriteLine(isChinese);
21    }
22 }
23    
判断是否是中文字符串
技术图片
 1 using System;
 2 
 3 public class Example
 4 {
 5    public static void Main()
 6    {
 7         string CString = "ability";
 8         //    正则表达式
 9         System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^[A-Za-z]+$");
10         //    IsMatch
11         Console.WriteLine(reg.IsMatch(CString));
12    }
13 }
14    
判断是否是英文字符串

 判断是否是中文

isChinese = true;
break;

 

以上是关于判断是否是中文英文字符串的主要内容,如果未能解决你的问题,请参考以下文章