代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication2
{
public static class Program
{
static void Main(string[] args)
{
bool checkstr = HasChinese("123h");
bool checkstr2 = HasChinese("123h发");
}
//判断表示是否全为英文
/// <summary>
/// 判断字符串中是否包含中文
/// </summary>
/// <param name="str">需要判断的字符串</param>
/// <returns>判断结果</returns>
public static bool HasChinese(this string str)
{
return Regex.IsMatch(str, @"[\u4e00-\u9fa5]");
}
}
}
本实力包含了 c#怎么判断是否包含汉子的作为创建文件夹的时候进行判断极为有用