Изменения в новых версиях / C# 3.0

using System;
using System.Collections.Generic;

class Program {
    static void Main() {
        // *** before: ***
        // the type was spelled out twice, and the longer it was the harder
        // the line became to read
        Dictionary<stringList<int>> scoresOld = new Dictionary<string,
            List<int>>();
        scoresOld["Ann"] = new List<int>();
        scoresOld["Ann"].Add(5);
        foreach (KeyValuePair<stringList<int>> pair in scoresOld)
            Console.WriteLine(pair.Key + " " + pair.Value.Count);

        // *** in version 3.0: ***
        var scores = new Dictionary<stringList<int>>(); // taken from the
        //right side
        scores["Ann"] = new List<int>();
        scores["Ann"].Add(5);
        foreach (var pair in scores)
            Console.WriteLine(pair.Key + " " + pair.Value.Count);

        var count = 0;                 // int
        var ratio = 1.5;               // double
        var name = "Bob";              // string
        Console.WriteLine(count + " " + ratio + " " + name);

        // var is not "any type": the type is fixed at the declaration and
        // never changes afterwards
        // count = "seven";            // would not compile
        //var empty;                  // would not compile: nothing to deduce
        //from
        // var nothing = null;         // and neither would this one
    }
}