System.Collections.CaseInsensitiveHashCodeProvider Class

Assembly: Mscorlib.dll
Namespace: System.Collections
Summary
Supplies a hash code for an object, using a hashing algorithm that ignores the case of strings.
C# Syntax:
[Serializable]
public class CaseInsensitiveHashCodeProvider : IHashCodeProvider
Remarks
CaseInsensitiveHashCodeProvider implements the IHashCodeProvider interface supporting case-insensitive comparisons on strings, just as CaseInsensitiveComparer implements the IComparer interface supporting case-insensitive comparisons on strings.

The objects used as keys by a Hashtable are typically required to implement or inherit the Object.GetHashCode and Object.Equals methods, which are case-sensitive. In order to ignore the case in strings, the Hashtable constructor must be passed a reference to an object that derives from both the CaseInsensitiveHashCodeProvider class and the CaseInsensitiveComparer class, so that CaseInsensitiveHashCodeProvider.GetHashCode and CaseInsensitiveComparer.Compare can be used instead.

See also:
System.Collections Namespace | Hashtable | IHashCodeProvider | CaseInsensitiveComparer

System.Collections.CaseInsensitiveHashCodeProvider Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the CaseInsensitiveHashCodeProvider class using the current CultureInfo.
ctor #2 Overloaded:
.ctor(CultureInfo culture)

Initializes a new instance of the CaseInsensitiveHashCodeProvider class using the current CultureInfo.
Public Properties
Default Read-only

Gets an instance of CaseInsensitiveHashCodeProvider that is always available.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
Overloaded:
GetHashCode()

See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetHashCode Overloaded:
GetHashCode(object obj)

Returns a hash code for the given object, using a hashing algorithm that ignores the case of strings.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Collections.CaseInsensitiveHashCodeProvider Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the CaseInsensitiveHashCodeProvider class using the current CultureInfo.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public CaseInsensitiveHashCodeProvider();
Remarks
The CultureInfo provides information about casing.
See also:
CultureInfo

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the CaseInsensitiveHashCodeProvider class using the current CultureInfo.
C# Syntax:
public CaseInsensitiveHashCodeProvider(
   CultureInfo culture
);
Parameters:

culture

The CultureInfo to use for the new CaseInsensitiveHashCodeProvider.

Exceptions
Exception Type Condition
ArgumentNullException culture is null.
Remarks
The CultureInfo provides information about casing.
See also:
CultureInfo

Return to top


Property: Default (read-only)
Summary
Gets an instance of CaseInsensitiveHashCodeProvider that is always available.
C# Syntax:
public static CaseInsensitiveHashCodeProvider Default {get;}

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~CaseInsensitiveHashCodeProvider();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: GetHashCode(
   object obj
)
Summary
Returns a hash code for the given object, using a hashing algorithm that ignores the case of strings.
C# Syntax:
public int GetHashCode(
   object obj
);
Parameters:

obj

The Object for which a hash code is to be returned.

Return Value:
A hash code for the given object, using a hashing algorithm that ignores the case of strings.
Exceptions
Exception Type Condition
ArgumentNullException obj is null.
Implements:
IHashCodeProvider.GetHashCode
Remarks
The return value from this method must not be persisted for two reasons. First, the hash function of a class might be altered to generate a better distribution, rendering any values from the old hash function useless. Second, the default implementation of this class does not guarantee that the same value will be returned by different instances.
See also:
Object.GetHashCode

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.