public void DictionaryInitialization() { //dictionaries can be initialized like this with any type var a = new Dictionary <int, int> { { 1, 1 }, { 1, 2 } }; //any class that implements IEnumerable and has a 2 parameter Add() method can be initialized like this var b = new MyDictionary() { { 1, 1 }, { 2, 2 } }; //any class that implements IEnumerable and has an Add() method with any number of parameters can be initialized var c = new MyThreeParameterAdd() { { "a", 2, 'c' } }; }
public void DictionaryInitialization() { //dictionaries can be initialized like this with any type var a = new Dictionary<int, int> { {1, 1}, {1, 2} }; //any class that implements IEnumerable and has a 2 parameter Add() method can be initialized like this var b = new MyDictionary() { {1, 1}, {2, 2} }; //any class that implements IEnumerable and has an Add() method with any number of parameters can be initialized var c = new MyThreeParameterAdd() { {"a", 2, 'c'} }; }