CSharp examples for Custom Type:Object Initializer
Dictionary Initialization Syntax
using System.Collections.Generic; using System.ComponentModel; class DictionaryInitialization { static void Main() {/* ww w.j av a 2 s.c o m*/ var objectInitializer = new Dictionary<string, int> { ["A"] = 20, ["B"] = 30, ["B"] = 40 }; var collectionInitializer = new Dictionary<string, int> { { "A", 20 }, { "B", 30 }, { "B", 40 } }; } }