|
I just read that the Silverlight 1.1 next release (they didn't say if it would be another Alpha or if it would be Beta 1) is going to have some breaking changes in it. This is one of the few times in Microsoft history that I've actually been both pleased to see breaking changes and that Microsoft has actually had the ba...er...guts ... to break things that need breaking instead of piling on scar tissue for the sake of backwards compatibility.
Basically what they've done is outlawed the use of non-generic collections. This should, in my opinion, have been done immediately with the release of the .NET Framework 2.0, but I guess this will have to do. In the spirit of keeping the Silverlight runtime as small as possible, I couldn't agree more with the decision to scrap the non-generic collections like the ArrayList, the non-generic Hashtable, etc.
Here are a list of the classes that will be deprecated, and their Generic equivalents (pulled from this blog post on the BCL blog):
| Non-generic | Generic replacement |
| ArrayList | List<T> |
| BitArray | List<Boolean> [note that this isn’t stored as compactly as BitArray but represents the same information] |
| CaseInsensitiveComparer | Comparer<T> |
| CaseInsensitiveHashCodeProvider | Comparer<T> |
| CollectionBase | Collection<T> |
| Comparer | Comparer<T> |
| CompatibleComparer | Comparer<T> |
| DictionaryBase | KeyedCollection<K,V> |
| DictionaryEntry | KeyValuePair<K,V> |
| Hashtable | Dictionary<K,V> |
| KeyValuePairs | KeyValuePair<K,V> |
| Queue | Queue<T> |
| ReadOnlyCollectionBase | ReadOnlyCollection<T> |
| SortedList | List<T> |
| Stack | Stack<T> |
If you really don't know at compile time what type you're going to be stuffing in your collection, and you can't even infer a base class or a common interface used by all the items in the collection, then you can always resort to using things like List<object>, however, I have yet to see a piece of code that couldn't be made slightly more type-safe than that.