In C # 2.0, we can initialize arrays and lists with values, such as:
int[] a = { 0, 1, 2, 3 }; int[,] b = { { 0, 1 }, { 1, 2 }, { 2, 3 } }; List<int> c = new List<int>(new int[] { 0, 1, 2, 3 });
I would like to do the same with Dictionary. I know that you can do this easily in C # 3.0 onwards:
Dictionary<int, int> d = new Dictionary<int, int> { { 0, 1 }, { 1, 2 }, { 2, 3 } };
But this does not work in C # 2.0. Is there any workaround for this without using Add or based on an existing collection?
source share