CompareInfo クラス

定義

カルチャごとに異なる文字列比較を行うための一連のメソッドを実装します。

public ref class CompareInfo
public ref class CompareInfo sealed : System::Runtime::Serialization::IDeserializationCallback
public ref class CompareInfo : System::Runtime::Serialization::IDeserializationCallback
public class CompareInfo
public sealed class CompareInfo : System.Runtime.Serialization.IDeserializationCallback
public class CompareInfo : System.Runtime.Serialization.IDeserializationCallback
[System.Serializable]
public class CompareInfo : System.Runtime.Serialization.IDeserializationCallback
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class CompareInfo : System.Runtime.Serialization.IDeserializationCallback
type CompareInfo = class
type CompareInfo = class
    interface IDeserializationCallback
[<System.Serializable>]
type CompareInfo = class
    interface IDeserializationCallback
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type CompareInfo = class
    interface IDeserializationCallback
Public Class CompareInfo
Public NotInheritable Class CompareInfo
Implements IDeserializationCallback
Public Class CompareInfo
Implements IDeserializationCallback
継承
CompareInfo
属性
実装

次の例は、オブジェクトに関連付CultureInfoけられているオブジェクトがCompareInfo文字列比較にどのように影響するかを示しています。

using namespace System;
using namespace System::Text;
using namespace System::Globalization;

int main()
{
    array<String^>^ sign = gcnew array<String^> { "<", "=", ">" };

    // The code below demonstrates how strings compare
    // differently for different cultures.
    String^ s1 = "Coté"; 
    String^ s2 = "coté";
    String^ s3 = "côte";

    // Set sort order of strings for French in France.
    CompareInfo^ ci = (gcnew CultureInfo("fr-FR"))->CompareInfo;
    Console::WriteLine(L"The LCID for {0} is {1}.", ci->Name, ci->LCID);

    // Display the result using fr-FR Compare of Coté = coté.
    Console::WriteLine(L"fr-FR Compare: {0} {2} {1}",
        s1, s2, sign[ci->Compare(s1, s2, CompareOptions::IgnoreCase) + 1]);

    // Display the result using fr-FR Compare of coté > côte.
    Console::WriteLine(L"fr-FR Compare: {0} {2} {1}",
        s2, s3, sign[ci->Compare(s2, s3, CompareOptions::None) + 1]);

    // Set sort order of strings for Japanese as spoken in Japan.
    ci = (gcnew CultureInfo("ja-JP"))->CompareInfo;
    Console::WriteLine(L"The LCID for {0} is {1}.", ci->Name, ci->LCID);

    // Display the result using ja-JP Compare of coté < côte.
    Console::WriteLine("ja-JP Compare: {0} {2} {1}",
        s2, s3, sign[ci->Compare(s2, s3) + 1]);
}

// This code produces the following output.
//
// The LCID for fr-FR is 1036.
// fr-FR Compare: Coté = coté
// fr-FR Compare: coté > côte
// The LCID for ja-JP is 1041.
// ja-JP Compare: coté < côte
using System;
using System.Text;
using System.Globalization;

public sealed class App
{
    static void Main(string[] args)
    {
        String[] sign = new String[] { "<", "=", ">" };

        // The code below demonstrates how strings compare
        // differently for different cultures.
        String s1 = "Coté", s2 = "coté", s3 = "côte";

        // Set sort order of strings for French in France.
        CompareInfo ci = new CultureInfo("fr-FR").CompareInfo;
        Console.WriteLine("The LCID for {0} is {1}.", ci.Name, ci.LCID);

        // Display the result using fr-FR Compare of Coté = coté.  	
        Console.WriteLine("fr-FR Compare: {0} {2} {1}",
            s1, s2, sign[ci.Compare(s1, s2, CompareOptions.IgnoreCase) + 1]);

        // Display the result using fr-FR Compare of coté > côte.
        Console.WriteLine("fr-FR Compare: {0} {2} {1}",
            s2, s3, sign[ci.Compare(s2, s3, CompareOptions.None) + 1]);

        // Set sort order of strings for Japanese as spoken in Japan.
        ci = new CultureInfo("ja-JP").CompareInfo;
        Console.WriteLine("The LCID for {0} is {1}.", ci.Name, ci.LCID);

        // Display the result using ja-JP Compare of coté < côte.
        Console.WriteLine("ja-JP Compare: {0} {2} {1}",
            s2, s3, sign[ci.Compare(s2, s3) + 1]);
    }
}

// This code produces the following output.
//
// The LCID for fr-FR is 1036.
// fr-FR Compare: Coté = coté
// fr-FR Compare: coté > côte
// The LCID for ja-JP is 1041.
// ja-JP Compare: coté < côte
Imports System.Text
Imports System.Globalization

NotInheritable Public Class App
    Shared Sub Main(ByVal args() As String) 
        Dim sign() As String = {"<", "=", ">"}
        
        ' The code below demonstrates how strings compare 
        ' differently for different cultures.
        Dim s1 As String = "Coté"
        Dim s2 As String = "coté"
        Dim s3 As String = "côte"
        
        ' Set sort order of strings for French in France.
        Dim ci As CompareInfo = New CultureInfo("fr-FR").CompareInfo
        Console.WriteLine("The LCID for {0} is {1}.", ci.Name, ci.LCID)
        
        ' Display the result using fr-FR Compare of Coté = coté.  	
        Console.WriteLine("fr-FR Compare: {0} {2} {1}", _
                          s1, s2, sign((ci.Compare(s1, s2, CompareOptions.IgnoreCase) + 1)))
        
        ' Display the result using fr-FR Compare of coté > côte.
        Console.WriteLine("fr-FR Compare: {0} {2} {1}", _
                          s2, s3, sign((ci.Compare(s2, s3, CompareOptions.None) + 1)))
        
        ' Set sort order of strings for Japanese as spoken in Japan.
        ci = New CultureInfo("ja-JP").CompareInfo
        Console.WriteLine("The LCID for {0} is {1}.", ci.Name, ci.LCID)
        
        ' Display the result using ja-JP Compare of coté < côte. 
        Console.WriteLine("ja-JP Compare: {0} {2} {1}", _
                          s2, s3, sign((ci.Compare(s2, s3) + 1)))
    End Sub
End Class

' This code produces the following output.
' 
' The LCID for fr-FR is 1036.
' fr-FR Compare: Coté = coté
' fr-FR Compare: coté > côte
' The LCID for ja-JP is 1041.
' ja-JP Compare: coté < côte

注釈

この API の詳細については、「 CompareInfo の補足 API 解説」を参照してください。

プロパティ

LCID

現在の CompareInfo に対して適切な形式のカルチャ識別子を取得します。

Name

この CompareInfo による並べ替え操作に使用されるカルチャの名前を取得します。

Version

文字列の比較および並べ替えに使用される Unicode のバージョンに関する情報を取得します。

メソッド

Compare(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions)

2 つの読み取り専用文字スパンを比較します。

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

文字列のセクションと別の文字列のセクションとを比較します。

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

指定した CompareOptions 値を使用して、ある文字列のセクションと別の文字列のセクションとを比較します。

Compare(String, Int32, String, Int32)

文字列の末尾部分と別の文字列の末尾部分とを比較します。

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

指定した CompareOptions 値を使用して、文字列の末尾部分と別の文字列の末尾部分とを比較します。

Compare(String, String)

2 つの文字列を比較します。

Compare(String, String, CompareOptions)

指定した CompareOptions 値を使用して、2 つの文字列を比較します。

Equals(Object)

指定したオブジェクトが、現在の CompareInfo オブジェクトと等しいかどうかを判断します。

GetCompareInfo(Int32)

指定した識別子のカルチャに関連付けられている新しい CompareInfo オブジェクトを初期化します。

GetCompareInfo(Int32, Assembly)

指定したカルチャに関連付けられ、指定した CompareInfo 内の文字列比較メソッドを使用する新しい Assembly オブジェクトを初期化します。

GetCompareInfo(String)

指定した名前のカルチャに関連付けられている新しい CompareInfo オブジェクトを初期化します。

GetCompareInfo(String, Assembly)

指定したカルチャに関連付けられ、指定した CompareInfo 内の文字列比較メソッドを使用する新しい Assembly オブジェクトを初期化します。

GetHashCode()

現在の CompareInfo のハッシュ関数として機能し、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造に使用されます。

GetHashCode(ReadOnlySpan<Char>, CompareOptions)

指定した比較オプションに基づいて文字スパンに対するハッシュ コードを取得します。

GetHashCode(String, CompareOptions)

指定した比較オプションに基づいて文字列のハッシュ コードを取得します。

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

指定の入力の並べ替えキーを計算します。

GetSortKey(String)

指定した文字列の並べ替えキーを取得します。

GetSortKey(String, CompareOptions)

指定した CompareOptions 値を使用して、指定した文字列の SortKey オブジェクトを取得します。

GetSortKeyLength(ReadOnlySpan<Char>, CompareOptions)

指定の入力から生成される並べ替えキーのバイト総数を取得します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IndexOf(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions)

指定の読み取り専用文字スパン内で最初に現れる部分文字列を検索します。

IndexOf(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions, Int32)

ソース文字列内での部分文字列の最初の出現を検索します。

IndexOf(ReadOnlySpan<Char>, Rune, CompareOptions)

指定の読み取り専用文字スパン内で最初に現れる Rune を検索します。

IndexOf(String, Char)

指定した文字を検索し、検索対象文字列全体内で最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, Char, CompareOptions)

指定した CompareOptions 値を使用して、指定した文字を検索し、検索対象文字列全体内でその文字が最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, Char, Int32)

指定した文字を検索し、検索対象文字列の指定したインデックスから文字列の末尾までの範囲内で、その文字が最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, Char, Int32, CompareOptions)

指定した CompareOptions 値を使用して、指定した文字を検索し、検索対象文字列の指定したインデックスから文字列の末尾までのセクション内で、その文字が最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, Char, Int32, Int32)

指定した文字を検索し、検索対象文字列の指定したインデックスから始まり、指定した数の要素を含んでいる範囲内で、その文字が最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, Char, Int32, Int32, CompareOptions)

指定した CompareOptions 値を使用して、指定した文字を検索し、検索対象文字列の指定したインデックスから始まり、指定した数の要素を含んでいる範囲内で、その文字が最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, String)

指定した部分文字列を検索し、検索対象文字列全体内で、その部分文字列が最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, String, CompareOptions)

指定した CompareOptions 値を使用して、指定した部分文字列を検索し、検索対象文字列全体内で、その部分文字列が最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, String, Int32)

指定した部分文字列を検索し、検索対象文字列の指定したインデックスから文字列の末尾までの範囲内で、その部分文字列が最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, String, Int32, CompareOptions)

指定した CompareOptions 値を使用して、指定した部分文字列を検索し、検索対象文字列の指定したインデックスから文字列の末尾までの範囲内で、その部分文字列が最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, String, Int32, Int32)

指定した部分文字列を検索し、検索対象文字列の指定したインデックスから始まり、指定した数の要素を含んでいる範囲内で、その部分文字列が最初に出現する位置の 0 から始まるインデックス番号を返します。

IndexOf(String, String, Int32, Int32, CompareOptions)

指定した CompareOptions 値を使用して、指定した部分文字列を検索し、検索対象文字列の指定したインデックスから始まり、指定した数の要素を含んでいる範囲内で、その部分文字列が最初に出現する位置の 0 から始まるインデックス番号を返します。

IsPrefix(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions)

読み取り専用文字スパンが特定のプレフィックスから始まるかどうかを決定します。

IsPrefix(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions, Int32)

文字列が特定のプレフィックスで始まるかどうかを判断します。

IsPrefix(String, String)

指定した検索対象文字列が指定したプリフィックスで始まるかどうかを判断します。

IsPrefix(String, String, CompareOptions)

指定した CompareOptions 値を使用して、指定した検索対象文字列が指定したプレフィックスで始まるかどうかを判断します。

IsSortable(Char)

指定した Unicode 文字の並べ替えが可能かどうかを示します。

IsSortable(ReadOnlySpan<Char>)

指定した Unicode 読み取り専用文字スパンの並べ替えが可能かどうかを示します。

IsSortable(Rune)

指定した Rune が並べ替え可能かどうかを示します。

IsSortable(String)

指定した Unicode 文字列の並べ替えが可能かどうかを示します。

IsSuffix(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions)

読み取り専用文字スパンが特定のサフィックスから終わるかどうかを決定します。

IsSuffix(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions, Int32)

文字列が特定のサフィックスで終わるかどうかを判断します。

IsSuffix(String, String)

指定した検索対象文字列が指定したサフィックスで終わるかどうかを判断します。

IsSuffix(String, String, CompareOptions)

指定した CompareOptions 値を使用して、指定した検索対象文字列が、指定したサフィックスで終わるかどうかを判断します。

LastIndexOf(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions)

指定の読み取り専用文字スパン内で最後に現れる部分文字列を検索します。

LastIndexOf(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions, Int32)

ソース文字列内での部分文字列の最後の出現を検索します。

LastIndexOf(ReadOnlySpan<Char>, Rune, CompareOptions)

指定の読み取り専用文字スパン内で最後に現れる Rune を検索します。

LastIndexOf(String, Char)

指定した文字を検索し、検索対象文字列全体内でその文字が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, Char, CompareOptions)

指定した CompareOptions 値を使用して、指定した文字を検索し、検索対象文字列全体内でその文字が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, Char, Int32)

指定した文字を検索し、検索対象文字列の先頭から指定したインデックスまでの範囲内で、その文字列が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, Char, Int32, CompareOptions)

指定した CompareOptions 値を使用して、指定した文字を検索し、検索対象の文字列の先頭から指定したインデックスまでの範囲内で、その文字が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, Char, Int32, Int32)

指定した文字を検索し、検索対象文字列の指定したインデックスで終了し、指定した数の要素を含んでいる範囲内で、その文字が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, Char, Int32, Int32, CompareOptions)

指定した CompareOptions 値を使用して、指定した文字を検索し、検索対象文字列の指定したインデックスで終了し、指定した数の要素を含んでいる範囲内で、その文字が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, String)

指定した部分文字列を検索し、検索対象文字列全体内で、その部分文字列が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, String, CompareOptions)

指定した CompareOptions 値を使用して、指定した部分文字列を検索し、検索対象文字列全体内でその部分文字列が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, String, Int32)

指定した部分文字列を検索し、検索対象文字列の先頭から指定したインデックスまでの範囲内で、その部分文字列が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, String, Int32, CompareOptions)

指定した CompareOptions 値を使用して、指定した部分文字列を検索し、検索対象の文字列の先頭から指定したインデックスまでの範囲内で、その部分文字列が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, String, Int32, Int32)

指定した部分文字列を検索し、検索対象文字列の指定したインデックスで終了し、指定した数の要素を含んでいる範囲内で、その部分文字列が最後に出現する位置の 0 から始まるインデックス番号を返します。

LastIndexOf(String, String, Int32, Int32, CompareOptions)

指定した CompareOptions 値を使用して、指定した部分文字列を検索し、検索対象文字列の指定したインデックスで終了し、指定した数の要素を含んでいる範囲内で、その部分文字列が最後に出現する位置の 0 から始まるインデックス番号を返します。

MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在の CompareInfo オブジェクトを表す文字列を返します。

明示的なインターフェイスの実装

IDeserializationCallback.OnDeserialization(Object)

オブジェクト グラフ全体が逆シリアル化された時点で実行します。

拡張メソッド

GetStringComparer(CompareInfo, CompareOptions)

指定した CompareInfo オブジェクトの、カルチャを区別する文字列比較ルールに基づいて、StringComparer オブジェクトを返します。

適用対象

こちらもご覧ください