Benutzer-Werkzeuge

Webseiten-Werkzeuge


csharp:c

C# List to Dictionary

            List<Product> listProducts = new List<Product>
            {
                new Product { ID= 1001, Name = "Mobile", Price = 800 },
                new Product { ID= 1002, Name = "Laptop", Price = 900 },
                new Product { ID= 1003, Name = "Desktop", Price = 800 }
            };
            Dictionary<int, string> productsDictionary = listProducts.ToDictionary(x => x.ID, x => x.Name);

Quelle

csharp/c.txt · Zuletzt geändert: 2021/09/21 09:56 von ronny

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki