The introduction of generics will be a welcome addition to C# and VB in 2.0, except the change is little more disruptive than I would have thought. Consider the current use of Hashtable:
Hashtable lastNames = new Hashtable();
lastNames.Add("Beatrice", "Arthur");
lastNames.Add("Lucille", "Ball");
object name = lastNames["Audrey"];
if (name == null)
{
lastNames.Add("Audrey", "Hepburn");
}
Now here is how it might look after an porting to use the generic type Dictionary<K,V>:
Dictionary<string, string> lastNames;
lastNames = new Dictionary<string, string> ();
lastNames.Add("Beatrice", "Arthur");
lastNames.Add("Lucille", "Ball");
// the next line throws KeyNotFoundException
string name = lastNames["Audrey"];
if (name == null)
{
lastNames.Add("Audrey", "Hepburn");
}
In Beta 1 the indexer throws...