Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
CollectionsUtil Class

Creates collections that ignore the case in strings.

Namespace:  System.Collections.Specialized
Assembly:  System (in System.dll)
Visual Basic (Declaration)
Public Class CollectionsUtil
Visual Basic (Usage)
Dim instance As CollectionsUtil
C#
public class CollectionsUtil
Visual C++
public ref class CollectionsUtil
JScript
public class CollectionsUtil

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.

System..::.Object
  System.Collections.Specialized..::.CollectionsUtil

A Hashtable can support one writer and multiple readers concurrently. To support multiple writers, all operations must be done through the wrapper returned by the Synchronized method.

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.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Avoid using the methods on this class      David M. Kean - MSFT   |   Edit   |   Show History

The Hashtable and SortedList instances returned by this type perform a culture-sensitive, case-insensitive comparison using the current thread's culture (retrieived via CultureInfo.CurrentCulture). If using the Hashtable or SortedList to store identifiers such as file paths, registry keys, and environment variables, or making security decisions based on its contents, construct a Hashtable or SortedList manually using the comparer returned by StringComparer.OrdinalIgnoreCase.

For more information on the correct way to compare strings, see the following article:

New Recommendations for Using Strings in Microsoft .NET 2.0
http://msdn2.microsoft.com/en-us/library/ms973919.aspx

Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker