StringComparer的最低字符串

时间:2018-01-22 17:08:10

标签: c# .net-2.0

是否有a字符串StringComparer.OrdinalIgnoreCase.Compare(a,b)返回值< 0表示所有b不等于a

其他字符串文化是否存在类似的字符串a

1 个答案:

答案 0 :(得分:0)

a设置为null似乎可以满足这一条件。

> StringComparer.OrdinalIgnoreCase.Compare(null, null)
0 // this is fine as a is equal to b
> StringComparer.OrdinalIgnoreCase.Compare(null, 'a')
-1
> StringComparer.OrdinalIgnoreCase.Compare(null, "")
-1
> StringComparer.OrdinalIgnoreCase.Compare(null, string.Empty)
-1
> StringComparer.OrdinalIgnoreCase.Compare(null, "-1")
-1
> StringComparer.OrdinalIgnoreCase.Compare(null, "-")
-1
> StringComparer.OrdinalIgnoreCase.Compare(null, "-")
-1