Creates collections that ignore the case in strings.
Assembly: System (in System.dll)
Thetype exposes the following members.
|CreateCaseInsensitiveHashtable()||Creates a new case-insensitive instance of the Hashtable class with the default initial capacity.|
|CreateCaseInsensitiveHashtable(IDictionary)||Copies the entries from the specified dictionary to a new case-insensitive instance of the Hashtable class with the same initial capacity as the number of entries copied.|
|CreateCaseInsensitiveHashtable(Int32)||Creates a new case-insensitive instance of the Hashtable class with the specified initial capacity.|
|CreateCaseInsensitiveSortedList||Creates a new instance of the SortedList class that ignores the case of strings.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
These methods generate a case-insensitive instance of the collection using case-insensitive implementations of the hash code provider and the comparer. The resulting instance can be used like any other instances of that class, although it may behave differently.
For example, suppose two objects with the keys "hello" and "HELLO" are to be added to a hash table. A case-sensitive hash table would create two different entries; whereas, a case-insensitive hash table would throw an exception when adding the second object.
The following example uses two collections, a hash table and a sorted list, to hold population values for a group of cities. The values are retrieved from the collections by using the city names as keys. The city names are in mixed case to show their use as case-insensitive keys.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
A SortedList can support multiple readers concurrently, as long as the collection is not modified. To guarantee the thread safety of the SortedList, all operations must be done through the wrapper returned by the Synchronized method.
Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.