CompareInfo.GetSortKey 方法

定義

取得字串的 SortKey 物件。Gets a SortKey object for a string.

多載

GetSortKey(String)

取得指定之字串的排序鍵。Gets the sort key for the specified string.

GetSortKey(String, CompareOptions)

使用指定的 SortKey 值,取得指定之字串的 CompareOptions 物件。Gets a SortKey object for the specified string using the specified CompareOptions value.

GetSortKey(ReadOnlySpan<Char>, Span<Byte>, CompareOptions)

計算指定輸入的排序鍵。Computes a sort key for the specified input.

GetSortKey(String)

取得指定之字串的排序鍵。Gets the sort key for the specified string.

public:
 System::Globalization::SortKey ^ GetSortKey(System::String ^ source);
public:
 virtual System::Globalization::SortKey ^ GetSortKey(System::String ^ source);
public System.Globalization.SortKey GetSortKey (string source);
public virtual System.Globalization.SortKey GetSortKey (string source);
member this.GetSortKey : string -> System.Globalization.SortKey
abstract member GetSortKey : string -> System.Globalization.SortKey
override this.GetSortKey : string -> System.Globalization.SortKey
Public Function GetSortKey (source As String) As SortKey
Public Overridable Function GetSortKey (source As String) As SortKey

參數

source
String

取得 SortKey 物件的字串。The string for which a SortKey object is obtained.

傳回

SortKey

SortKey 物件,包含指定之字串的排序鍵。The SortKey object that contains the sort key for the specified string.

備註

字串中的每個字元都有幾個分類加權分類,包括腳本、字母、大小寫和變音符號加權。Each character in a string is given several categories of sort weights, including script, alphabetic, case, and diacritic weights. 排序索引鍵是特定字串的這些權數的儲存機制。A sort key is the repository of these weights for a particular string. 例如,排序索引鍵可能包含字母權數的字串,後面接著一個大小寫加權的字串等等。For example, a sort key might contain a string of alphabetic weights, followed by a string of case weights, and so on. GetSortKey方法相當於具有 LCMAP_SORTKEY 旗標的 WINDOWS API 方法 LCMapStringThe GetSortKey method is equivalent to the Windows API method LCMapString with the LCMAP_SORTKEY flag.

另請參閱

適用於

GetSortKey(String, CompareOptions)

使用指定的 SortKey 值,取得指定之字串的 CompareOptions 物件。Gets a SortKey object for the specified string using the specified CompareOptions value.

public:
 System::Globalization::SortKey ^ GetSortKey(System::String ^ source, System::Globalization::CompareOptions options);
public:
 virtual System::Globalization::SortKey ^ GetSortKey(System::String ^ source, System::Globalization::CompareOptions options);
public System.Globalization.SortKey GetSortKey (string source, System.Globalization.CompareOptions options);
public virtual System.Globalization.SortKey GetSortKey (string source, System.Globalization.CompareOptions options);
member this.GetSortKey : string * System.Globalization.CompareOptions -> System.Globalization.SortKey
abstract member GetSortKey : string * System.Globalization.CompareOptions -> System.Globalization.SortKey
override this.GetSortKey : string * System.Globalization.CompareOptions -> System.Globalization.SortKey
Public Function GetSortKey (source As String, options As CompareOptions) As SortKey
Public Overridable Function GetSortKey (source As String, options As CompareOptions) As SortKey

參數

source
String

取得 SortKey 物件的字串。The string for which a SortKey object is obtained.

options
CompareOptions

下列其中一個或多個列舉值的位元組合,這些值會定義排序鍵的計算方式:IgnoreCaseIgnoreSymbolsIgnoreNonSpaceIgnoreWidthIgnoreKanaTypeStringSortA bitwise combination of one or more of the following enumeration values that define how the sort key is calculated: IgnoreCase, IgnoreSymbols, IgnoreNonSpace, IgnoreWidth, IgnoreKanaType, and StringSort.

傳回

SortKey

SortKey 物件,包含指定之字串的排序鍵。The SortKey object that contains the sort key for the specified string.

例外狀況

options 包含無效的 CompareOptions 值。options contains an invalid CompareOptions value.

備註

字串中的每個字元都有幾個分類加權分類,包括腳本、字母、大小寫和變音符號加權。Each character in a string is given several categories of sort weights, including script, alphabetic, case, and diacritic weights. 排序索引鍵是特定字串的這些權數的儲存機制。A sort key is the repository of these weights for a particular string. 例如,排序索引鍵可能包含字母權數的字串,後面接著一個大小寫加權的字串等等。For example, a sort key might contain a string of alphabetic weights, followed by a string of case weights, and so on. GetSortKey方法相當於具有 LCMAP_SORTKEY 旗標的 WINDOWS API 方法 LCMapStringThe GetSortKey method is equivalent to the Windows API method LCMapString with the LCMAP_SORTKEY flag.

另請參閱

適用於

GetSortKey(ReadOnlySpan<Char>, Span<Byte>, CompareOptions)

計算指定輸入的排序鍵。Computes a sort key for the specified input.

public int GetSortKey (ReadOnlySpan<char> source, Span<byte> destination, System.Globalization.CompareOptions options = System.Globalization.CompareOptions.None);
member this.GetSortKey : ReadOnlySpan<char> * Span<byte> * System.Globalization.CompareOptions -> int
Public Function GetSortKey (source As ReadOnlySpan(Of Char), destination As Span(Of Byte), Optional options As CompareOptions = System.Globalization.CompareOptions.None) As Integer

參數

source
ReadOnlySpan<Char>

要取得其排序鍵的文字。The text to get the sort key for.

destination
Span<Byte>

要在其中排序所產生排序鍵位元組的緩衝區。The buffer into which the resulting sort key bytes are stored.

options
CompareOptions

要用於計算排序鍵的選擇性 CompareOptions 列舉值組合。An optional combination of CompareOptions enumeration values to use for computing the sort key. 預設值是 NoneThe default value is None.

傳回

Int32

寫入至 destination 的位元組數。The number of bytes written to destination.

例外狀況

destination 太小,無法包含產生的排序鍵;或 options 包含不支援的旗標;或無法使用目前 CompareInfo 下所需的 CompareOptions 來處理 sourcedestination is too small to contain the resulting sort key; or options contains an unsupported flag; or source cannot be processed using the desired CompareOptions under the current CompareInfo.

備註

使用 GetSortKeyLength(ReadOnlySpan<Char>, CompareOptions) 查詢所需的大小 destinationUse GetSortKeyLength(ReadOnlySpan<Char>, CompareOptions) to query the required size of destination. 您可以將大於必要的輸出緩衝區提供給這個方法。It is acceptable to provide a larger-than-necessary output buffer to this method.

適用於