Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ASCII 范围为 0 - 127,因此只需检查该范围:
char c = 'a';//or whatever char you have bool isAscii = c < 128;
bool HasNonASCIIChars(string str) { return (System.Text.Encoding.UTF8.GetByteCount(str) != str.Length); }