Skip to content

M_Cyjb_StringUtil_NaturalCompare_2

CYJB edited this page Mar 20, 2024 · 2 revisions

StringUtil.NaturalCompare 方法 (String, String, StringComparison)

比较两个字符串,字符串中的数字部分会按照数字顺序比较。

Namespace: Cyjb
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6

语法

C#

public static int NaturalCompare(
	string? strA,
	string? strB,
	StringComparison comparisonType = StringComparison.CurrentCulture
)

参数

 

strA
Type: System.String
要比较的第一个字符串。
strB
Type: System.String
要比较的第二个字符串。
comparisonType (Optional)
Type: System.StringComparison
比较中要使用的规则。

返回值

Type: Int32
一个 32 位带符号整数,指示两个字符串之间的顺序。  

条件
小于零 strA 在排序顺序中位于 strB 之前。
strAstrB 在排序顺序中的位置相同。
大于零 strA 在排序顺序中位于 strB 之后。

参见

Reference

StringUtil 类
NaturalCompare 重载
Cyjb 命名空间

Clone this wiki locally