C# 保留字符串中的中文
/// <summary> /// 保留中文字符串 /// </summary> /// <returns></returns> public static string RetainChineseString(this string str) { StringBuilder chineseString = new StringBuilder(); for (int i = 0; i < str.Length; i++) { if (str[i] >= 0x4E00 && str[i] <= 0x9FA5) //汉字 { chineseString.Append(str[i]); } } return chineseString.Length>0? chineseString.ToString():string.Empty; }