1: // Object and Dictionary Collection Initializers Without Constructor
2: Dictionary<string, Product> pDictionary = new Dictionary<string, Product>
3: { 4: {"HHH", new Product { ProductName = "H", ProductPrice = 800 } }, 5: {"III", new Product { ProductName = "I", ProductPrice = 900 } } 6: };
7: foreach (KeyValuePair<string, Product> pPair in pDictionary)
8: { 9: Console.WriteLine(pPair.Value.ToString());
10: }
11: /* Output:
12: * ProductName: H, ProductPrice: 800
13: * ProductName: I, ProductPrice: 900
14: */