共用方式為


LogicalStringComparer.Compare 方法

定義

多載

Compare(String, String)

執行兩個字串之間的邏輯比較。

Compare(String, Int32, Int32, String, Int32, Int32)

在兩個字串的子字串之間執行邏輯比較。

Compare(String, String)

執行兩個字串之間的邏輯比較。

public override int Compare(string? s1, string? s2);
override this.Compare : string * string -> int
Public Overrides Function Compare (s1 As String, s2 As String) As Integer

參數

s1
String

要比較的第一個字串。

s2
String

要比較的第二個字串。

傳回

帶正負號的整數,表示 x 和 y 的相對值,如下表所示:

意義
小於零在排序次序中,s1 會排在 s2 之前。
s1 出現在排序次序中的位置和 s2 相同。
大於零在排序次序中,s1 會排在 s2 之後。

適用於

Compare(String, Int32, Int32, String, Int32, Int32)

在兩個字串的子字串之間執行邏輯比較。

public int Compare(string? s1, int start1, int length1, string? s2, int start2, int length2);
override this.Compare : string * int * int * string * int * int -> int
Public Function Compare (s1 As String, start1 As Integer, length1 As Integer, s2 As String, start2 As Integer, length2 As Integer) As Integer

參數

s1
String

要用於比較中的第一個字串。

start1
Int32

s1 中子字串的位置。

length1
Int32

內的 s1子字串長度。

s2
String

要用於比較的第二個字串。

start2
Int32

s2 中子字串的位置。

length2
Int32

內的 s2子字串長度。

傳回

帶正負號的整數,表示 x 和 y 的相對值,如下表所示:

意義
小於零 s1 中的子字串的排序次序在 s2 中的子字串之前。
中的 s1 子字串會與 排序順序中的 s2 子字串位於相同的位置。
大於零 s1 中的子字串的排序次序在 s2 中的子字串之後。

適用於