System.Collections classes are obsolete

Collection classes like ArrayList, SortedList, Stack and Hashtable will shortly be obsoleted (i.e. the ObsoleteAttribute will be applied to them in upcoming .NET Framework builds).  You can start to see this in the Silverlight Alpha (i.e. the Obsolete attribute), but they will be physically unavailable in the release version.


More details can be found in a recent Base Class Library Team blog entry Non-Generic Collections to be Removed from Silverlight.


Even if you don’t plan on writing Silverlight-compatible code you should avoid using the types detailed in the BCL Teams blog because they’ll be obsolete in other future versions of the .NET Framework.

5 thoughts on “System.Collections classes are obsolete”

  1. According to the comments section of the cited BCL blog entry, there are no plans to remove non-generic collections from the .NET framework. This removal only applies to Silverlight.

    And it’s a good thing too, since there are situations that require non-generic collections.

    For example, the SoapFormatter class doesn’t support serializing generic collections. Currently, an easy way to persist data to a file (for example), is to add the data to a non-generic dictionary (like ListDictionary, Hashtable, etc), and simply serialize it to a file via SoapFormatter. This results in an easy to read XML file containing the data (and the file is Soap conformant). To deserialize the data from the file, use SoapFormatter to deserialize it into a non-generic dictionary, then retrieve the data from the dictionary. This couldn’t be done with a generic dictionary because A) they can only take values of a specific type, and B) SoapFormatter doesn’t support serializing generic collections. Using Dictionaryas a generic dictionary would get around (A) but not (B). (Note that the XmlSerializer doesn’t support serializing IDictionary collections, so you couldn’t use that either.)

    That’s just one example of many times were non-generic collections are needed. But they should be removed for Silverlight to keep Silverlight as small as possible.

  2. It’s really a headache trying to migrate to Silverlight!

    class Person
    {

    protected Hashtable _lstProperties;

    public Hashtable Properties < <-- Property type cannot be known apriori! It's template class!
    {
    get { return _lstProperties; }
    set { _lstProperties = value; }
    }
    }

    And property really is a template class ...

    class Property
    {

    }

    And Silverlight stipulates that every collection be System.Collections.Generic – this means even if I hand out the source code, it can’t be consumed from Silverlight.

  3. To tell you the truth, Silverlight IS REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY piece of S+H+I+T!

    Slow, Stupid, and more even collection class missing, you are like a PIG head to remove those that we already familiar with.

    I will have all my programmers move away from SUCH a S+H+I+T platform, php is more friendly , faster than you, the PIG, Microsoft is going to die soon.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>