Tag: unicode escapes

六位数unicode逃逸价值比较

我有一个六位数的unicode字符,例如U+100000 ,我希望与我的C#代码中的另一个char进行比较。 我对MSDN文档的阅读是这个字符不能用char表示,而必须用string表示。 字符文字中不允许使用U + 10000到U + 10FFFF范围内的Unicode字符,并使用字符串文字中的Unicode代理项对表示 我觉得我遗漏了一些显而易见的东西,但你怎么能让跟随比较正常工作: public bool IsCharLessThan(char myChar, string upperBound) { return myChar < upperBound; // will not compile as a char is not comparable to a string } Assert.IsTrue(AnExample('\u0066', "\u100000")); Assert.IsFalse(AnExample("\u100000", "\u100000")); // again won't compile as this is a string and not a char 编辑 k,我想我需要两种方法,一种是接受字符,另一种是接受“大字符”即字符串。 所以: public […]