为什么我会看到从.NET的StartsWith这个意外的行为?我会、意外、行为、StartsWith

2023-09-04 08:26:07 作者:╰ 狐狸的悲傷.

这必须是一个.NET的错误,对吧?

This must be a .NET bug, right?

KonNy.StartsWith(昆)返回false,而KonNy.StartsWith(高)KonN.StartsWith(昆)返回true。

"KonNy".StartsWith("Kon") returns false, while "KonNy".StartsWith("Ko") and "KonN".StartsWith("Kon") return true.

这有什么,我在这里失踪?

Is there anything I'm missing here?

推荐答案

从注​​释重复:

我不知道.NET具体,但我怀疑你可能会注意到这个现象,如果 StartsWith 遵循整理其中南阳是一个字母,如匈牙利。如果我是对的,如果你改变你的排序规则是中性的,你的错误将消失。 :)

I don't know .NET specifically, but I suspected you might observe this phenomenon if StartsWith followed a collation where nny was a single letter, such as Hungarian. If I'm right and if you change your collation to a neutral one, your "bug" would disappear. :)