using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HuanMeng.DotNetCore.Utility; /// /// 字符串扩展 /// public static class StringExtend { /// /// 判断字符串是否包含中文字符(使用字符遍历) /// /// 需要检查的字符串 /// 如果包含中文字符,则返回 true;否则返回 false public static bool ContainsChineseOptimized(this string input) { if (string.IsNullOrEmpty(input)) { return false; } foreach (char c in input) { if (c >= '\u4e00' && c <= '\u9fa5') { return true; } } return false; } }