CaseInsensitiveHashCodeProvider CaseInsensitiveHashCodeProvider CaseInsensitiveHashCodeProvider CaseInsensitiveHashCodeProvider Class

정의

경고

이 API는 현재 사용되지 않습니다.

문자열의 대/소문자를 구분하지 않는 해시 알고리즘을 사용하여 개체에 대해 해시 코드를 제공합니다.Supplies a hash code for an object, using a hashing algorithm that ignores the case of strings.

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

예제

다음 코드 예제에서는 대/소문자 구분 해시 테이블 및 대/소문자 해시 테이블을 만들고 모두 동일한 요소를 포함 하는 경우에 해당 동작의 차이점을 설명 합니다.The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements.

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

설명

CaseInsensitiveHashCodeProvider 구현 된 IHashCodeProvider 처럼 문자열 대/소문자 구분 비교를 지 원하는 인터페이스 CaseInsensitiveComparer 구현를 IComparer 문자열에 대/소문자 구분 비교를 지 원하는 인터페이스.CaseInsensitiveHashCodeProvider implements the IHashCodeProvider interface supporting case-insensitive comparisons on strings, just as CaseInsensitiveComparer implements the IComparer interface supporting case-insensitive comparisons on strings.

중요

사용 하는 권장 하지 않습니다는 CaseInsensitiveHashCodeProvider 새로운 개발에 대 한 클래스입니다.We don't recommend that you use the CaseInsensitiveHashCodeProvider class for new development. 사용 하는 권장 대신 합니다 System.StringComparer 에서 반환 된 개체를 StringComparer.CurrentCultureIgnoreCase, StringComparer.InvariantCultureIgnoreCase, 또는 StringComparer.OrdinalIgnoreCase 속성입니다.Instead, we recommend that you use the System.StringComparer object returned by the StringComparer.CurrentCultureIgnoreCase, StringComparer.InvariantCultureIgnoreCase, or StringComparer.OrdinalIgnoreCase property.

키로 사용 하는 개체를 Hashtable 재정의 하는 데 필요한 합니다 Object.GetHashCode 메서드 (또는 IHashCodeProvider 인터페이스) 및 Object.Equals 메서드 (또는 IComparer 인터페이스).The objects used as keys by a Hashtable are required to override the Object.GetHashCode method (or the IHashCodeProvider interface) and the Object.Equals method (or the IComparer interface). 메서드나 인터페이스 구현의 대/소문자 구분; 동일한 방식으로 처리 해야 합니다. 그렇지 않은 경우는 Hashtable 올바르게 작동할 수 있습니다.The implementation of both methods or interfaces must handle case sensitivity the same way; otherwise, the Hashtable might behave incorrectly. 예를 들어, 만들 때를 Hashtable를 사용 하 여이 클래스를 사용 해야 합니다 CaseInsensitiveComparer 클래스 또는 대/소문자 IComparer 구현.For example, when creating a Hashtable, you must use this class with the CaseInsensitiveComparer class or any case-insensitive IComparer implementation.

생성자

CaseInsensitiveHashCodeProvider() CaseInsensitiveHashCodeProvider() CaseInsensitiveHashCodeProvider() CaseInsensitiveHashCodeProvider()

현재 스레드의 CaseInsensitiveHashCodeProvider를 사용하여 CurrentCulture 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the CaseInsensitiveHashCodeProvider class using the CurrentCulture of the current thread.

CaseInsensitiveHashCodeProvider(CultureInfo) CaseInsensitiveHashCodeProvider(CultureInfo) CaseInsensitiveHashCodeProvider(CultureInfo) CaseInsensitiveHashCodeProvider(CultureInfo)

지정된 CaseInsensitiveHashCodeProvider를 사용하여 CultureInfo 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the CaseInsensitiveHashCodeProvider class using the specified CultureInfo.

속성

Default Default Default Default

현재 스레드의 CaseInsensitiveHashCodeProvider와 관련되어 있고 항상 사용 가능한 CurrentCulture의 인스턴스를 가져옵니다.Gets an instance of CaseInsensitiveHashCodeProvider that is associated with the CurrentCulture of the current thread and that is always available.

DefaultInvariant DefaultInvariant DefaultInvariant DefaultInvariant

CaseInsensitiveHashCodeProvider와 관련되어 있고 항상 사용 가능한 InvariantCulture의 인스턴스를 가져옵니다.Gets an instance of CaseInsensitiveHashCodeProvider that is associated with InvariantCulture and that is always available.

메서드

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetHashCode(Object) GetHashCode(Object) GetHashCode(Object) GetHashCode(Object)

문자열의 대/소문자를 구분하지 않는 해시 알고리즘을 사용하여 지정된 개체의 해시 코드를 반환합니다.Returns a hash code for the given object, using a hashing algorithm that ignores the case of strings.

GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)

적용 대상

추가 정보