CaseInsensitiveHashCodeProviderとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CaseInsensitiveHashCodeProviderの意味・解説 

CaseInsensitiveHashCodeProvider クラス

メモ : このクラスは、互換性のために残されています。

文字列大文字と小文字区別しないハッシュ アルゴリズム使用してオブジェクトハッシュ コード提供します

名前空間: System.Collections
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ObsoleteAttribute("Please use StringComparer instead.")>
 _
<ComVisibleAttribute(True)> _
Public Class CaseInsensitiveHashCodeProvider
    Implements IHashCodeProvider
Dim instance As CaseInsensitiveHashCodeProvider
[SerializableAttribute] 
[ObsoleteAttribute("Please use StringComparer instead.")] 
[ComVisibleAttribute(true)] 
public class CaseInsensitiveHashCodeProvider
 : IHashCodeProvider
[SerializableAttribute] 
[ObsoleteAttribute(L"Please use StringComparer instead.")] 
[ComVisibleAttribute(true)] 
public ref class CaseInsensitiveHashCodeProvider
 : IHashCodeProvider
/** @attribute SerializableAttribute() */ 
/** @attribute ObsoleteAttribute("Please use StringComparer instead.")
 */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CaseInsensitiveHashCodeProvider
 implements IHashCodeProvider
SerializableAttribute 
ObsoleteAttribute("Please use StringComparer instead.") 
ComVisibleAttribute(true) 
public class CaseInsensitiveHashCodeProvider
 implements IHashCodeProvider
解説解説

CaseInsensitiveHashCodeProvider は、文字列大文字と小文字区別しない比較サポートする IHashCodeProvider インターフェイス実装しています。同様に、CaseInsensitiveComparer は、文字列大文字と小文字区別しない比較サポートする IComparer インターフェイス実装しています。

Hashtableキーとして使用されるオブジェクトは、Object.GetHashCode メソッド (または IHashCodeProvider インターフェイス) およびObject.Equals メソッド (または IComparer インターフェイス) を実装または継承している必要がありますメソッドまたはインターフェイスのどちらの実装でも、大文字と小文字区別を同じ方法処理する必要がありますそのように実装されていないと、Hashtable正しく動作しない場合あります。たとえば、Hashtable作成するとき、このクラスは、CaseInsensitiveComparer クラス大文字と小文字区別しない IComparer 実装と共に使用する必要があります

使用例使用例

次に示すのは、大文字と小文字区別するハッシュ テーブルと、大文字と小文字区別しないハッシュ テーブル作成するコード例です。それぞれのハッシュ テーブル含まれている要素が同じでも、両者動作異なることがわかります

Imports System
Imports System.Collections
Imports System.Globalization

Public Class SamplesHashtable

   Public Shared Sub Main()

      ' Create a Hashtable using the default hash code provider and
 the default comparer.
      Dim myHT1 As New Hashtable()
      myHT1.Add("FIRST", "Hello")
      myHT1.Add("SECOND", "World")
      myHT1.Add("THIRD", "!")

      ' Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      ' based on the culture of the current thread.
      Dim myHT2 As New Hashtable(New
 CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())
      myHT2.Add("FIRST", "Hello")
      myHT2.Add("SECOND", "World")
      myHT2.Add("THIRD", "!")

      ' Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      ' based on the InvariantCulture.
      Dim myHT3 As New Hashtable(CaseInsensitiveHashCodeProvider.DefaultInvariant,
 CaseInsensitiveComparer.DefaultInvariant)
      myHT3.Add("FIRST", "Hello")
      myHT3.Add("SECOND", "World")
      myHT3.Add("THIRD", "!")

      ' Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      ' based on the Turkish culture (tr-TR), where "I" is
 not the uppercase version of "i".
      Dim myCul As New CultureInfo("tr-TR")
      Dim myHT4 As New Hashtable(New
 CaseInsensitiveHashCodeProvider(myCul), New CaseInsensitiveComparer(myCul))
      myHT4.Add("FIRST", "Hello")
      myHT4.Add("SECOND", "World")
      myHT4.Add("THIRD", "!")

      ' Search for a key in each hashtable.
      Console.WriteLine("first is in myHT1: {0}",
 myHT1.ContainsKey("first"))
      Console.WriteLine("first is in myHT2: {0}",
 myHT2.ContainsKey("first"))
      Console.WriteLine("first is in myHT3: {0}",
 myHT3.ContainsKey("first"))
      Console.WriteLine("first is in myHT4: {0}",
 myHT4.ContainsKey("first"))

   End Sub 'Main 

End Class 'SamplesHashtable


'This code produces the following output.  Results vary depending on
 the system's culture settings.
'
'first is in myHT1: False
'first is in myHT2: True
'first is in myHT3: True
'first is in myHT4: False

using System;
using System.Collections;
using System.Globalization;

public class SamplesHashtable  {

   public static void Main()
  {

      // Create a Hashtable using the default hash code provider and
 the default comparer.
      Hashtable myHT1 = new Hashtable();
      myHT1.Add("FIRST", "Hello");
      myHT1.Add("SECOND", "World");
      myHT1.Add("THIRD", "!");

      // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      // based on the culture of the current thread.
      Hashtable myHT2 = new Hashtable( new
 CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer()
 );
      myHT2.Add("FIRST", "Hello");
      myHT2.Add("SECOND", "World");
      myHT2.Add("THIRD", "!");

      // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      // based on the InvariantCulture.
      Hashtable myHT3 = new Hashtable( CaseInsensitiveHashCodeProvider.DefaultInvariant,
 CaseInsensitiveComparer.DefaultInvariant );
      myHT3.Add("FIRST", "Hello");
      myHT3.Add("SECOND", "World");
      myHT3.Add("THIRD", "!");

      // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      // based on the Turkish culture (tr-TR), where "I" is
 not the uppercase version of "i".
      CultureInfo myCul = new CultureInfo( "tr-TR" );
      Hashtable myHT4 = new Hashtable( new
 CaseInsensitiveHashCodeProvider( myCul ), new CaseInsensitiveComparer(
 myCul ) );
      myHT4.Add("FIRST", "Hello");
      myHT4.Add("SECOND", "World");
      myHT4.Add("THIRD", "!");

      // Search for a key in each hashtable.
      Console.WriteLine( "first is in myHT1: {0}", myHT1.ContainsKey(
 "first" ) );
      Console.WriteLine( "first is in myHT2: {0}", myHT2.ContainsKey(
 "first" ) );
      Console.WriteLine( "first is in myHT3: {0}", myHT3.ContainsKey(
 "first" ) );
      Console.WriteLine( "first is in myHT4: {0}", myHT4.ContainsKey(
 "first" ) );

   }

}


/* 
This code produces the following output.  Results vary depending on the system's
 culture settings.

first is in myHT1: False
first is in myHT2: True
first is in myHT3: True
first is in myHT4: False

*/

using namespace System;
using namespace System::Collections;
using namespace System::Globalization;
int main()
{
   
   // Create a Hashtable using the default hash code provider and the
 default comparer.
   Hashtable^ myHT1 = gcnew Hashtable;
   myHT1->Add( "FIRST", "Hello" );
   myHT1->Add( "SECOND", "World" );
   myHT1->Add( "THIRD", "!" );
   
   // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
   // based on the culture of the current thread.
   Hashtable^ myHT2 = gcnew Hashtable( gcnew CaseInsensitiveHashCodeProvider,gcnew
 CaseInsensitiveComparer );
   myHT2->Add( "FIRST", "Hello" );
   myHT2->Add( "SECOND", "World" );
   myHT2->Add( "THIRD", "!" );
   
   // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
   // based on the InvariantCulture.
   Hashtable^ myHT3 = gcnew Hashtable( CaseInsensitiveHashCodeProvider::DefaultInvariant,CaseInsensitiveComparer::DefaultInvariant
 );
   myHT3->Add( "FIRST", "Hello" );
   myHT3->Add( "SECOND", "World" );
   myHT3->Add( "THIRD", "!" );
   
   // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
   // based on the Turkish culture (tr-TR), where "I" is not
 the uppercase version of "i".
   CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" );
   Hashtable^ myHT4 = gcnew Hashtable( gcnew CaseInsensitiveHashCodeProvider( myCul
 ),gcnew CaseInsensitiveComparer( myCul ) );
   myHT4->Add( "FIRST", "Hello" );
   myHT4->Add( "SECOND", "World" );
   myHT4->Add( "THIRD", "!" );
   
   // Search for a key in each hashtable.
   Console::WriteLine( "first is in myHT1: {0}", myHT1->ContainsKey(
 "first" ) );
   Console::WriteLine( "first is in myHT2: {0}", myHT2->ContainsKey(
 "first" ) );
   Console::WriteLine( "first is in myHT3: {0}", myHT3->ContainsKey(
 "first" ) );
   Console::WriteLine( "first is in myHT4: {0}", myHT4->ContainsKey(
 "first" ) );
}

/* 
This code produces the following output.  Results vary depending on the system's
 culture settings.

first is in myHT1: False
first is in myHT2: True
first is in myHT3: True
first is in myHT4: False

*/
import System.*;
import System.Collections.*;
import System.Globalization.*;

public class SamplesHashtable
{
    public static void main(String[]
 args)
    {
        // Create a Hashtable using the default hash code provider and
 the
        // default comparer.
        Hashtable myHT1 = new Hashtable();
        myHT1.Add("FIRST", "Hello");
        myHT1.Add("SECOND", "World");
        myHT1.Add("THIRD", "!");
          
        // Create a Hashtable using a case-insensitive code provider
 and a 
        // case-insensitive comparer, based on the culture of the 
        // current thread.
        Hashtable myHT2 = new Hashtable(new
 CaseInsensitiveHashCodeProvider(),
            new CaseInsensitiveComparer());
        myHT2.Add("FIRST", "Hello");
        myHT2.Add("SECOND", "World");
        myHT2.Add("THIRD", "!");
          
        // Create a Hashtable using a case-insensitive code provider
 and 
        // a case-insensitive comparer, based on the InvariantCulture.
        Hashtable myHT3 =  
            new Hashtable(CaseInsensitiveHashCodeProvider.get_DefaultInvariant()
,
            CaseInsensitiveComparer.get_DefaultInvariant());
        myHT3.Add("FIRST", "Hello");
        myHT3.Add("SECOND", "World");
        myHT3.Add("THIRD", "!");
          
        // Create a Hashtable using a case-insensitive code provider
 and a 
        // case-insensitive comparer, based on the Turkish culture (tr-TR),
 
        // where "I" is not the uppercase version of "i".
        CultureInfo myCul =  new CultureInfo("tr-TR");
        Hashtable myHT4 =  
            new Hashtable(new CaseInsensitiveHashCodeProvider(myCul),
 
            new CaseInsensitiveComparer(myCul));
        myHT4.Add("FIRST", "Hello");
        myHT4.Add("SECOND", "World");
        myHT4.Add("THIRD", "!");
          
        // Search for a key in each hashtable.
        Console.WriteLine("first is in myHT1: {0}",
 
            (System.Boolean)myHT1.ContainsKey("first"));
        Console.WriteLine("first is in myHT2: {0}",
 
            (System.Boolean)myHT2.ContainsKey("first"));
        Console.WriteLine("first is in myHT3: {0}",
 
            (System.Boolean)myHT3.ContainsKey("first"));
        Console.WriteLine("first is in myHT4: {0}",
 
            (System.Boolean)myHT4.ContainsKey("first"));
    } //main
} //SamplesHashtable

/* 
This code produces the following output.  Results vary depending on the system's
 
culture settings.

first is in myHT1: False
first is in myHT2: True
first is in myHT3: True
first is in myHT4: False

*/
継承階層継承階層
System.Object
  System.Collections.CaseInsensitiveHashCodeProvider
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CaseInsensitiveHashCodeProvider メンバ
System.Collections 名前空間
Hashtable
IHashCodeProvider
Thread.CurrentCulture
System.Globalization.CultureInfo
CaseInsensitiveComparer クラス
その他の技術情報
カルチャを認識しないコレクション操作実行

CaseInsensitiveHashCodeProvider コンストラクタ ()

現在のスレッドの Thread.CurrentCulture を使用して、CaseInsensitiveHashCodeProvider クラス新しインスタンス初期化します。

名前空間: System.Collections
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As New CaseInsensitiveHashCodeProvider
public CaseInsensitiveHashCodeProvider ()
public:
CaseInsensitiveHashCodeProvider ()
public CaseInsensitiveHashCodeProvider ()
public function CaseInsensitiveHashCodeProvider
 ()
解説解説
使用例使用例

次に示すのは、大文字と小文字区別するハッシュ テーブルと、大文字と小文字区別しないハッシュ テーブル作成するコード例です。それぞれのハッシュ テーブル含まれている要素が同じでも、両者動作異なることがわかります

Imports System
Imports System.Collections
Imports System.Globalization

Public Class SamplesHashtable

   Public Shared Sub Main()

      ' Create a Hashtable using the default hash code provider and
 the default comparer.
      Dim myHT1 As New Hashtable()
      myHT1.Add("FIRST", "Hello")
      myHT1.Add("SECOND", "World")
      myHT1.Add("THIRD", "!")

      ' Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      ' based on the culture of the current thread.
      Dim myHT2 As New Hashtable(New
 CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())
      myHT2.Add("FIRST", "Hello")
      myHT2.Add("SECOND", "World")
      myHT2.Add("THIRD", "!")

      ' Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      ' based on the InvariantCulture.
      Dim myHT3 As New Hashtable(CaseInsensitiveHashCodeProvider.DefaultInvariant,
 CaseInsensitiveComparer.DefaultInvariant)
      myHT3.Add("FIRST", "Hello")
      myHT3.Add("SECOND", "World")
      myHT3.Add("THIRD", "!")

      ' Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      ' based on the Turkish culture (tr-TR), where "I" is
 not the uppercase version of "i".
      Dim myCul As New CultureInfo("tr-TR")
      Dim myHT4 As New Hashtable(New
 CaseInsensitiveHashCodeProvider(myCul), New CaseInsensitiveComparer(myCul))
      myHT4.Add("FIRST", "Hello")
      myHT4.Add("SECOND", "World")
      myHT4.Add("THIRD", "!")

      ' Search for a key in each hashtable.
      Console.WriteLine("first is in myHT1: {0}",
 myHT1.ContainsKey("first"))
      Console.WriteLine("first is in myHT2: {0}",
 myHT2.ContainsKey("first"))
      Console.WriteLine("first is in myHT3: {0}",
 myHT3.ContainsKey("first"))
      Console.WriteLine("first is in myHT4: {0}",
 myHT4.ContainsKey("first"))

   End Sub 'Main 

End Class 'SamplesHashtable


'This code produces the following output.  Results vary depending on
 the system's culture settings.
'
'first is in myHT1: False
'first is in myHT2: True
'first is in myHT3: True
'first is in myHT4: False

using System;
using System.Collections;
using System.Globalization;

public class SamplesHashtable  {

   public static void Main()
  {

      // Create a Hashtable using the default hash code provider and
 the default comparer.
      Hashtable myHT1 = new Hashtable();
      myHT1.Add("FIRST", "Hello");
      myHT1.Add("SECOND", "World");
      myHT1.Add("THIRD", "!");

      // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      // based on the culture of the current thread.
      Hashtable myHT2 = new Hashtable( new
 CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer()
 );
      myHT2.Add("FIRST", "Hello");
      myHT2.Add("SECOND", "World");
      myHT2.Add("THIRD", "!");

      // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      // based on the InvariantCulture.
      Hashtable myHT3 = new Hashtable( CaseInsensitiveHashCodeProvider.DefaultInvariant,
 CaseInsensitiveComparer.DefaultInvariant );
      myHT3.Add("FIRST", "Hello");
      myHT3.Add("SECOND", "World");
      myHT3.Add("THIRD", "!");

      // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      // based on the Turkish culture (tr-TR), where "I" is
 not the uppercase version of "i".
      CultureInfo myCul = new CultureInfo( "tr-TR" );
      Hashtable myHT4 = new Hashtable( new
 CaseInsensitiveHashCodeProvider( myCul ), new CaseInsensitiveComparer(
 myCul ) );
      myHT4.Add("FIRST", "Hello");
      myHT4.Add("SECOND", "World");
      myHT4.Add("THIRD", "!");

      // Search for a key in each hashtable.
      Console.WriteLine( "first is in myHT1: {0}", myHT1.ContainsKey(
 "first" ) );
      Console.WriteLine( "first is in myHT2: {0}", myHT2.ContainsKey(
 "first" ) );
      Console.WriteLine( "first is in myHT3: {0}", myHT3.ContainsKey(
 "first" ) );
      Console.WriteLine( "first is in myHT4: {0}", myHT4.ContainsKey(
 "first" ) );

   }

}


/* 
This code produces the following output.  Results vary depending on the system's
 culture settings.

first is in myHT1: False
first is in myHT2: True
first is in myHT3: True
first is in myHT4: False

*/

using namespace System;
using namespace System::Collections;
using namespace System::Globalization;
int main()
{
   
   // Create a Hashtable using the default hash code provider and the
 default comparer.
   Hashtable^ myHT1 = gcnew Hashtable;
   myHT1->Add( "FIRST", "Hello" );
   myHT1->Add( "SECOND", "World" );
   myHT1->Add( "THIRD", "!" );
   
   // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
   // based on the culture of the current thread.
   Hashtable^ myHT2 = gcnew Hashtable( gcnew CaseInsensitiveHashCodeProvider,gcnew
 CaseInsensitiveComparer );
   myHT2->Add( "FIRST", "Hello" );
   myHT2->Add( "SECOND", "World" );
   myHT2->Add( "THIRD", "!" );
   
   // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
   // based on the InvariantCulture.
   Hashtable^ myHT3 = gcnew Hashtable( CaseInsensitiveHashCodeProvider::DefaultInvariant,CaseInsensitiveComparer::DefaultInvariant
 );
   myHT3->Add( "FIRST", "Hello" );
   myHT3->Add( "SECOND", "World" );
   myHT3->Add( "THIRD", "!" );
   
   // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
   // based on the Turkish culture (tr-TR), where "I" is not
 the uppercase version of "i".
   CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" );
   Hashtable^ myHT4 = gcnew Hashtable( gcnew CaseInsensitiveHashCodeProvider( myCul
 ),gcnew CaseInsensitiveComparer( myCul ) );
   myHT4->Add( "FIRST", "Hello" );
   myHT4->Add( "SECOND", "World" );
   myHT4->Add( "THIRD", "!" );
   
   // Search for a key in each hashtable.
   Console::WriteLine( "first is in myHT1: {0}", myHT1->ContainsKey(
 "first" ) );
   Console::WriteLine( "first is in myHT2: {0}", myHT2->ContainsKey(
 "first" ) );
   Console::WriteLine( "first is in myHT3: {0}", myHT3->ContainsKey(
 "first" ) );
   Console::WriteLine( "first is in myHT4: {0}", myHT4->ContainsKey(
 "first" ) );
}

/* 
This code produces the following output.  Results vary depending on the system's
 culture settings.

first is in myHT1: False
first is in myHT2: True
first is in myHT3: True
first is in myHT4: False

*/
import System.*;
import System.Collections.*;
import System.Globalization.*;

public class SamplesHashtable
{
    public static void main(String[]
 args)
    {
        // Create a Hashtable using the default hash code provider and
 the
        // default comparer.
        Hashtable myHT1 = new Hashtable();
        myHT1.Add("FIRST", "Hello");
        myHT1.Add("SECOND", "World");
        myHT1.Add("THIRD", "!");
          
        // Create a Hashtable using a case-insensitive code provider
 and a 
        // case-insensitive comparer, based on the culture of the 
        // current thread.
        Hashtable myHT2 = new Hashtable(new
 CaseInsensitiveHashCodeProvider(),
            new CaseInsensitiveComparer());
        myHT2.Add("FIRST", "Hello");
        myHT2.Add("SECOND", "World");
        myHT2.Add("THIRD", "!");
          
        // Create a Hashtable using a case-insensitive code provider
 and 
        // a case-insensitive comparer, based on the InvariantCulture.
        Hashtable myHT3 =  
            new Hashtable(CaseInsensitiveHashCodeProvider.get_DefaultInvariant()
,
            CaseInsensitiveComparer.get_DefaultInvariant());
        myHT3.Add("FIRST", "Hello");
        myHT3.Add("SECOND", "World");
        myHT3.Add("THIRD", "!");
          
        // Create a Hashtable using a case-insensitive code provider
 and a 
        // case-insensitive comparer, based on the Turkish culture (tr-TR),
 
        // where "I" is not the uppercase version of "i".
        CultureInfo myCul =  new CultureInfo("tr-TR");
        Hashtable myHT4 =  
            new Hashtable(new CaseInsensitiveHashCodeProvider(myCul),
 
            new CaseInsensitiveComparer(myCul));
        myHT4.Add("FIRST", "Hello");
        myHT4.Add("SECOND", "World");
        myHT4.Add("THIRD", "!");
          
        // Search for a key in each hashtable.
        Console.WriteLine("first is in myHT1: {0}",
 
            (System.Boolean)myHT1.ContainsKey("first"));
        Console.WriteLine("first is in myHT2: {0}",
 
            (System.Boolean)myHT2.ContainsKey("first"));
        Console.WriteLine("first is in myHT3: {0}",
 
            (System.Boolean)myHT3.ContainsKey("first"));
        Console.WriteLine("first is in myHT4: {0}",
 
            (System.Boolean)myHT4.ContainsKey("first"));
    } //main
} //SamplesHashtable

/* 
This code produces the following output.  Results vary depending on the system's
 
culture settings.

first is in myHT1: False
first is in myHT2: True
first is in myHT3: True
first is in myHT4: False

*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CaseInsensitiveHashCodeProvider クラス
CaseInsensitiveHashCodeProvider メンバ
System.Collections 名前空間
Thread.CurrentCulture
System.Globalization.CultureInfo
System.Globalization.CompareInfo
その他の技術情報
カルチャを認識しないコレクション操作実行

CaseInsensitiveHashCodeProvider コンストラクタ (CultureInfo)

System.Globalization.CultureInfo指定してCaseInsensitiveHashCodeProvider クラス新しインスタンス初期化します。

名前空間: System.Collections
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    culture As CultureInfo _
)
Dim culture As CultureInfo

Dim instance As New CaseInsensitiveHashCodeProvider(culture)
public CaseInsensitiveHashCodeProvider (
    CultureInfo culture
)
public:
CaseInsensitiveHashCodeProvider (
    CultureInfo^ culture
)
public CaseInsensitiveHashCodeProvider (
    CultureInfo culture
)
public function CaseInsensitiveHashCodeProvider
 (
    culture : CultureInfo
)

パラメータ

culture

新しい CaseInsensitiveHashCodeProvider で使用する System.Globalization.CultureInfo。

例外例外
例外種類条件

ArgumentNullException

culturenull 参照 (Visual Basic では Nothing) です。

解説解説
使用例使用例

次に示すのは、大文字と小文字区別するハッシュ テーブルと、大文字と小文字区別しないハッシュ テーブル作成するコード例です。それぞれのハッシュ テーブル含まれている要素が同じでも、両者動作異なることがわかります

Imports System
Imports System.Collections
Imports System.Globalization

Public Class SamplesHashtable

   Public Shared Sub Main()

      ' Create a Hashtable using the default hash code provider and
 the default comparer.
      Dim myHT1 As New Hashtable()
      myHT1.Add("FIRST", "Hello")
      myHT1.Add("SECOND", "World")
      myHT1.Add("THIRD", "!")

      ' Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      ' based on the culture of the current thread.
      Dim myHT2 As New Hashtable(New
 CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())
      myHT2.Add("FIRST", "Hello")
      myHT2.Add("SECOND", "World")
      myHT2.Add("THIRD", "!")

      ' Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      ' based on the InvariantCulture.
      Dim myHT3 As New Hashtable(CaseInsensitiveHashCodeProvider.DefaultInvariant,
 CaseInsensitiveComparer.DefaultInvariant)
      myHT3.Add("FIRST", "Hello")
      myHT3.Add("SECOND", "World")
      myHT3.Add("THIRD", "!")

      ' Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      ' based on the Turkish culture (tr-TR), where "I" is
 not the uppercase version of "i".
      Dim myCul As New CultureInfo("tr-TR")
      Dim myHT4 As New Hashtable(New
 CaseInsensitiveHashCodeProvider(myCul), New CaseInsensitiveComparer(myCul))
      myHT4.Add("FIRST", "Hello")
      myHT4.Add("SECOND", "World")
      myHT4.Add("THIRD", "!")

      ' Search for a key in each hashtable.
      Console.WriteLine("first is in myHT1: {0}",
 myHT1.ContainsKey("first"))
      Console.WriteLine("first is in myHT2: {0}",
 myHT2.ContainsKey("first"))
      Console.WriteLine("first is in myHT3: {0}",
 myHT3.ContainsKey("first"))
      Console.WriteLine("first is in myHT4: {0}",
 myHT4.ContainsKey("first"))

   End Sub 'Main 

End Class 'SamplesHashtable


'This code produces the following output.  Results vary depending on
 the system's culture settings.
'
'first is in myHT1: False
'first is in myHT2: True
'first is in myHT3: True
'first is in myHT4: False

using System;
using System.Collections;
using System.Globalization;

public class SamplesHashtable  {

   public static void Main()
  {

      // Create a Hashtable using the default hash code provider and
 the default comparer.
      Hashtable myHT1 = new Hashtable();
      myHT1.Add("FIRST", "Hello");
      myHT1.Add("SECOND", "World");
      myHT1.Add("THIRD", "!");

      // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      // based on the culture of the current thread.
      Hashtable myHT2 = new Hashtable( new
 CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer()
 );
      myHT2.Add("FIRST", "Hello");
      myHT2.Add("SECOND", "World");
      myHT2.Add("THIRD", "!");

      // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      // based on the InvariantCulture.
      Hashtable myHT3 = new Hashtable( CaseInsensitiveHashCodeProvider.DefaultInvariant,
 CaseInsensitiveComparer.DefaultInvariant );
      myHT3.Add("FIRST", "Hello");
      myHT3.Add("SECOND", "World");
      myHT3.Add("THIRD", "!");

      // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
      // based on the Turkish culture (tr-TR), where "I" is
 not the uppercase version of "i".
      CultureInfo myCul = new CultureInfo( "tr-TR" );
      Hashtable myHT4 = new Hashtable( new
 CaseInsensitiveHashCodeProvider( myCul ), new CaseInsensitiveComparer(
 myCul ) );
      myHT4.Add("FIRST", "Hello");
      myHT4.Add("SECOND", "World");
      myHT4.Add("THIRD", "!");

      // Search for a key in each hashtable.
      Console.WriteLine( "first is in myHT1: {0}", myHT1.ContainsKey(
 "first" ) );
      Console.WriteLine( "first is in myHT2: {0}", myHT2.ContainsKey(
 "first" ) );
      Console.WriteLine( "first is in myHT3: {0}", myHT3.ContainsKey(
 "first" ) );
      Console.WriteLine( "first is in myHT4: {0}", myHT4.ContainsKey(
 "first" ) );

   }

}


/* 
This code produces the following output.  Results vary depending on the system's
 culture settings.

first is in myHT1: False
first is in myHT2: True
first is in myHT3: True
first is in myHT4: False

*/

using namespace System;
using namespace System::Collections;
using namespace System::Globalization;
int main()
{
   
   // Create a Hashtable using the default hash code provider and the
 default comparer.
   Hashtable^ myHT1 = gcnew Hashtable;
   myHT1->Add( "FIRST", "Hello" );
   myHT1->Add( "SECOND", "World" );
   myHT1->Add( "THIRD", "!" );
   
   // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
   // based on the culture of the current thread.
   Hashtable^ myHT2 = gcnew Hashtable( gcnew CaseInsensitiveHashCodeProvider,gcnew
 CaseInsensitiveComparer );
   myHT2->Add( "FIRST", "Hello" );
   myHT2->Add( "SECOND", "World" );
   myHT2->Add( "THIRD", "!" );
   
   // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
   // based on the InvariantCulture.
   Hashtable^ myHT3 = gcnew Hashtable( CaseInsensitiveHashCodeProvider::DefaultInvariant,CaseInsensitiveComparer::DefaultInvariant
 );
   myHT3->Add( "FIRST", "Hello" );
   myHT3->Add( "SECOND", "World" );
   myHT3->Add( "THIRD", "!" );
   
   // Create a Hashtable using a case-insensitive code provider and
 a case-insensitive comparer,
   // based on the Turkish culture (tr-TR), where "I" is not
 the uppercase version of "i".
   CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" );
   Hashtable^ myHT4 = gcnew Hashtable( gcnew CaseInsensitiveHashCodeProvider( myCul
 ),gcnew CaseInsensitiveComparer( myCul ) );
   myHT4->Add( "FIRST", "Hello" );
   myHT4->Add( "SECOND", "World" );
   myHT4->Add( "THIRD", "!" );
   
   // Search for a key in each hashtable.
   Console::WriteLine( "first is in myHT1: {0}", myHT1->ContainsKey(
 "first" ) );
   Console::WriteLine( "first is in myHT2: {0}", myHT2->ContainsKey(
 "first" ) );
   Console::WriteLine( "first is in myHT3: {0}", myHT3->ContainsKey(
 "first" ) );
   Console::WriteLine( "first is in myHT4: {0}", myHT4->ContainsKey(
 "first" ) );
}

/* 
This code produces the following output.  Results vary depending on the system's
 culture settings.

first is in myHT1: False
first is in myHT2: True
first is in myHT3: True
first is in myHT4: False

*/
import System.*;
import System.Collections.*;
import System.Globalization.*;

public class SamplesHashtable
{
    public static void main(String[]
 args)
    {
        // Create a Hashtable using the default hash code provider and
 the
        // default comparer.
        Hashtable myHT1 = new Hashtable();
        myHT1.Add("FIRST", "Hello");
        myHT1.Add("SECOND", "World");
        myHT1.Add("THIRD", "!");
          
        // Create a Hashtable using a case-insensitive code provider
 and a 
        // case-insensitive comparer, based on the culture of the 
        // current thread.
        Hashtable myHT2 = new Hashtable(new
 CaseInsensitiveHashCodeProvider(),
            new CaseInsensitiveComparer());
        myHT2.Add("FIRST", "Hello");
        myHT2.Add("SECOND", "World");
        myHT2.Add("THIRD", "!");
          
        // Create a Hashtable using a case-insensitive code provider
 and 
        // a case-insensitive comparer, based on the InvariantCulture.
        Hashtable myHT3 =  
            new Hashtable(CaseInsensitiveHashCodeProvider.get_DefaultInvariant()
,
            CaseInsensitiveComparer.get_DefaultInvariant());
        myHT3.Add("FIRST", "Hello");
        myHT3.Add("SECOND", "World");
        myHT3.Add("THIRD", "!");
          
        // Create a Hashtable using a case-insensitive code provider
 and a 
        // case-insensitive comparer, based on the Turkish culture (tr-TR),
 
        // where "I" is not the uppercase version of "i".
        CultureInfo myCul =  new CultureInfo("tr-TR");
        Hashtable myHT4 =  
            new Hashtable(new CaseInsensitiveHashCodeProvider(myCul),
 
            new CaseInsensitiveComparer(myCul));
        myHT4.Add("FIRST", "Hello");
        myHT4.Add("SECOND", "World");
        myHT4.Add("THIRD", "!");
          
        // Search for a key in each hashtable.
        Console.WriteLine("first is in myHT1: {0}",
 
            (System.Boolean)myHT1.ContainsKey("first"));
        Console.WriteLine("first is in myHT2: {0}",
 
            (System.Boolean)myHT2.ContainsKey("first"));
        Console.WriteLine("first is in myHT3: {0}",
 
            (System.Boolean)myHT3.ContainsKey("first"));
        Console.WriteLine("first is in myHT4: {0}",
 
            (System.Boolean)myHT4.ContainsKey("first"));
    } //main
} //SamplesHashtable

/* 
This code produces the following output.  Results vary depending on the system's
 
culture settings.

first is in myHT1: False
first is in myHT2: True
first is in myHT3: True
first is in myHT4: False

*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CaseInsensitiveHashCodeProvider クラス
CaseInsensitiveHashCodeProvider メンバ
System.Collections 名前空間
System.Globalization.CultureInfo
その他の技術情報
カルチャを認識しないコレクション操作実行

CaseInsensitiveHashCodeProvider コンストラクタ

CaseInsensitiveHashCodeProvider クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
CaseInsensitiveHashCodeProvider () 現在のスレッドの Thread.CurrentCulture を使用してCaseInsensitiveHashCodeProvider クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

CaseInsensitiveHashCodeProvider (CultureInfo) System.Globalization.CultureInfo を指定してCaseInsensitiveHashCodeProvider クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

参照参照

関連項目

CaseInsensitiveHashCodeProvider クラス
CaseInsensitiveHashCodeProvider メンバ
System.Collections 名前空間
Thread.CurrentCulture
System.Globalization.CultureInfo
System.Globalization.CompareInfo

その他の技術情報

カルチャを認識しないコレクション操作実行

CaseInsensitiveHashCodeProvider プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ DefaultInvariant CultureInfo.InvariantCulture に関連付けられた、常に使用できる CaseInsensitiveHashCodeProviderインスタンス取得します
参照参照

関連項目

CaseInsensitiveHashCodeProvider クラス
System.Collections 名前空間
Hashtable
IHashCodeProvider
Thread.CurrentCulture
System.Globalization.CultureInfo
CaseInsensitiveComparer クラス

その他の技術情報

カルチャを認識しないコレクション操作実行

CaseInsensitiveHashCodeProvider メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CaseInsensitiveHashCodeProvider クラス
System.Collections 名前空間
Hashtable
IHashCodeProvider
Thread.CurrentCulture
System.Globalization.CultureInfo
CaseInsensitiveComparer クラス

その他の技術情報

カルチャを認識しないコレクション操作実行

CaseInsensitiveHashCodeProvider メンバ

文字列大文字と小文字区別しないハッシュ アルゴリズム使用してオブジェクトハッシュ コード提供します

CaseInsensitiveHashCodeProvider データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド CaseInsensitiveHashCodeProvider オーバーロードされます。 CaseInsensitiveHashCodeProvider クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ DefaultInvariant CultureInfo.InvariantCulture に関連付けられた、常に使用できる CaseInsensitiveHashCodeProviderインスタンス取得します
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CaseInsensitiveHashCodeProvider クラス
System.Collections 名前空間
Hashtable
IHashCodeProvider
Thread.CurrentCulture
System.Globalization.CultureInfo
CaseInsensitiveComparer クラス

その他の技術情報

カルチャを認識しないコレクション操作実行


このページでは「.NET Framework クラス ライブラリ リファレンス」からCaseInsensitiveHashCodeProviderを検索した結果を表示しています。
Weblioに収録されているすべての辞書からCaseInsensitiveHashCodeProviderを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCaseInsensitiveHashCodeProvider を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CaseInsensitiveHashCodeProvider」の関連用語

CaseInsensitiveHashCodeProviderのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CaseInsensitiveHashCodeProviderのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS