CaseInsensitiveHashCodeProvider 클래스

정의

주의

Please use StringComparer instead.

주의

CaseInsensitiveHashCodeProvider has been deprecated. Use StringComparer instead.

문자열의 대/소문자를 구분하지 않는 해시 알고리즘을 사용하여 개체에 대해 해시 코드를 제공합니다.

public ref class CaseInsensitiveHashCodeProvider : System::Collections::IHashCodeProvider
[System.Obsolete("Please use StringComparer instead.")]
public class CaseInsensitiveHashCodeProvider : System.Collections.IHashCodeProvider
[System.Obsolete("CaseInsensitiveHashCodeProvider has been deprecated. Use StringComparer instead.")]
public class CaseInsensitiveHashCodeProvider : System.Collections.IHashCodeProvider
[System.Serializable]
public class CaseInsensitiveHashCodeProvider : System.Collections.IHashCodeProvider
[System.Obsolete("Please use StringComparer instead.")]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class CaseInsensitiveHashCodeProvider : System.Collections.IHashCodeProvider
[<System.Obsolete("Please use StringComparer instead.")>]
type CaseInsensitiveHashCodeProvider = class
    interface IHashCodeProvider
[<System.Obsolete("CaseInsensitiveHashCodeProvider has been deprecated. Use StringComparer instead.")>]
type CaseInsensitiveHashCodeProvider = class
    interface IHashCodeProvider
[<System.Serializable>]
type CaseInsensitiveHashCodeProvider = class
    interface IHashCodeProvider
[<System.Obsolete("Please use StringComparer instead.")>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type CaseInsensitiveHashCodeProvider = class
    interface IHashCodeProvider
Public Class CaseInsensitiveHashCodeProvider
Implements IHashCodeProvider
상속
CaseInsensitiveHashCodeProvider
특성
구현

예제

다음 코드 예제에서는 대/소문자를 구분하는 해시 테이블과 대/소문자를 구분하지 않는 해시 테이블을 만들고 둘 다 동일한 요소를 포함하더라도 동작의 차이를 보여 줍니다.

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

*/
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

*/
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

End Class


'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

설명

CaseInsensitiveHashCodeProviderIHashCodeProvider 문자열에 대한 대/소문자를 구분하지 않는 비교를 지원하는 인터페이스를 구현하는 것처럼 CaseInsensitiveComparer 문자열에 대한 대/소문자를 구분하지 않는 비교를 지원하는 인터페이스를 구현 IComparer 합니다.

중요

새 개발에 클래스를 CaseInsensitiveHashCodeProvider 사용하지 않는 것이 좋습니다. 대신 , StringComparer.InvariantCultureIgnoreCase또는 StringComparer.OrdinalIgnoreCase 속성에서 System.StringComparer 반환된 개체를 StringComparer.CurrentCultureIgnoreCase사용하는 것이 좋습니다.

메서드(또는 인터페이스) 및 메서드(또는 인터페이스)를 재정 Object.GetHashCodeObject.Equals IHashCodeProvider 하려면 키 Hashtable 로 사용되는 개체가 IComparer 필요합니다. 메서드 또는 인터페이스의 구현은 대/소문자 구분을 동일한 방식으로 처리해야 합니다. 그렇지 않으면 잘못 동작할 Hashtable 수 있습니다. 예를 들어 만들 Hashtable때 클래스 또는 대/소문자를 구분 IComparer 하지 않는 구현과 함께 CaseInsensitiveComparer 이 클래스를 사용해야 합니다.

생성자

CaseInsensitiveHashCodeProvider()

현재 스레드의 CaseInsensitiveHashCodeProvider를 사용하여 CurrentCulture 클래스의 새 인스턴스를 초기화합니다.

CaseInsensitiveHashCodeProvider(CultureInfo)

지정된 CaseInsensitiveHashCodeProvider를 사용하여 CultureInfo 클래스의 새 인스턴스를 초기화합니다.

속성

Default

현재 스레드의 CaseInsensitiveHashCodeProvider와 관련되어 있고 항상 사용 가능한 CurrentCulture의 인스턴스를 가져옵니다.

DefaultInvariant

CaseInsensitiveHashCodeProvider와 관련되어 있고 항상 사용 가능한 InvariantCulture의 인스턴스를 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetHashCode(Object)

문자열의 대/소문자를 구분하지 않는 해시 알고리즘을 사용하여 지정된 개체의 해시 코드를 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보