CloudGaming/src/CloudGaming/Utile/HuanMeng.DotNetCore/Utility/StringExtend.cs
2024-12-13 23:21:28 +08:00

37 lines
852 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HuanMeng.DotNetCore.Utility;
/// <summary>
/// 字符串扩展
/// </summary>
public static class StringExtend
{
/// <summary>
/// 判断字符串是否包含中文字符(使用字符遍历)
/// </summary>
/// <param name="input">需要检查的字符串</param>
/// <returns>如果包含中文字符,则返回 true否则返回 false</returns>
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;
}
}