locked
Hashtable warning question RRS feed

  • Question

  • im using visual studio 2010 and .net 4.0 beta 2

    I am creating a class library and within one ofmy classes i have a line of code as follows:

    private Hashtable _Owners = Hashtable.Synchronized(new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer()));

    Now i get a warning saying the following:

    Warning 1 'System.Collections.Hashtable.Hashtable(System.Collections.IHashCodeProvider, System.Collections.IComparer)' is obsolete: 'Please use Hashtable(IEqualityComparer) instead.' C:\Users\radix\Desktop\radixIrcClassLibrary\radixIrcClassLibrary\Channel.cs 15 59 radixIrcClassLibrary

    Looked up the warning here:

    http://msdn.microsoft.com/en-us/library/ms132013(VS.100).aspx

    I am really confused as to what to do or to even bother at all since it is just a warning.
    any advice would be greatly appreciated, and thanks in advance.

    Wednesday, January 6, 2010 8:55 AM

Answers

  • It means that the new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer()) works but is obsolete and will be removed in next dot-net version. so it is better that replace it with new HashTable(IEqualityComparer).
    With best regards, Yasser Zamani
    Wednesday, January 6, 2010 9:12 AM

All replies

  • It means that the new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer()) works but is obsolete and will be removed in next dot-net version. so it is better that replace it with new HashTable(IEqualityComparer).
    With best regards, Yasser Zamani
    Wednesday, January 6, 2010 9:12 AM
  • i had used the following and got ride of the warning, but i will take your advice and use new HashTable(IEqualityComparer).

    [
    ObsoleteAttribute("Please use Hashtable(IDictionary, IEqualityComparer) instead.")]

    thanks :)
    Wednesday, January 6, 2010 9:21 AM
  • Great! you're welcome.
    With best regards, Yasser Zamani
    Wednesday, January 6, 2010 9:28 AM