Srikanth,
What you want to do is call the constructor that takes an IComparer,
passing a CaseInsensitiveComparer instance. Then, when you call Add with
the same key, it will throw an exception.
It should be noted that particular constructor is marked as Obsolete in
..NET 2.0, in favor of a new interface (only available in 2.0).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"Srikanth" <(E-Mail Removed)> wrote in message
news:eXLLkKL%(E-Mail Removed)...
> Hi
>
> Can any one say how to check a hashtable by ignoring the case of key
> supplied. I want the following requirement
>
> It should not allow the user to do the following
> Hashtable table = new Hashtable();
> a) table.Add("one",1);
> b) table.Add("One",1);
>
> by default it executes the above two statements with out any
> problem. But my intention is to throw an exception when the table contains
> the key by ignoring the case. Is there any way to implement like above?
>
>
> Thanks in advance
>
> Srikanth
>
>