C# 删除字符串中的中文(实例分享)
时间:2021-04-09 09:00:30|栏目:.NET代码|点击: 次
话不多说,请看代码
/// <summary>
/// 删除字符串中的中文
/// </summary>
public static string Delete中文(string str)
{
string retValue = str;
if (System.Text.RegularExpressions.Regex.IsMatch(str, @"[\u4e00-\u9fa5]"))
{
retValue = string.Empty;
var strsStrings = str.ToCharArray();
for (int index = 0; index < strsStrings.Length; index++)
{
if (strsStrings[index] >= 0x4e00 && strsStrings[index] <= 0x9fa5)
{
continue;
}
retValue += strsStrings[index];
}
}
return retValue;
}
上一篇:.net框架(framework)版本不匹配的解决方法
栏 目:.NET代码
下一篇:C#9.0新特性详解――顶级程序语句(Top-Level Programs)
本文标题:C# 删除字符串中的中文(实例分享)
本文地址:http://www.codeinn.net/misctech/97618.html






