M_Cyjb_StringUtil_NaturalCompare - CYJB/Cyjb GitHub Wiki
比较两个字符串,字符串中的数字部分会按照数字顺序比较。
Namespace: Cyjb
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6
C#
public static int NaturalCompare(
string? strA,
string? strB,
bool ignoreCase,
CultureInfo? culture
)
- strA
- Type: System.String
要比较的第一个字符串。 - strB
- Type: System.String
要比较的第二个字符串。 - ignoreCase
- Type: System.Boolean
是否在比较过程中忽略大小写。 - culture
- Type: System.Globalization.CultureInfo
区域性特定的比较信息。如果 culture 为null
, 则使用当前区域性。
Type: Int32
一个 32 位带符号整数,指示两个字符串之间的顺序。
值 | 条件 |
---|---|
小于零 | strA 在排序顺序中位于 strB 之前。 |
零 | strA 和 strB 在排序顺序中的位置相同。 |
大于零 | strA 在排序顺序中位于 strB 之后。 |