IEnumerable to Dictionary .NET 3.5

suggest change

Create a Dictionary<TKey, TValue> from an IEnumerable<T>:

using System;
using System.Collections.Generic;
using System.Linq;
public class Fruits
{
    public int Id { get; set; }
    public string Name { get; set; }
}
var fruits = new[]
{ 
    new Fruits { Id = 8 , Name = "Apple" },
    new Fruits { Id = 3 , Name = "Banana" },
    new Fruits { Id = 7 , Name = "Mango" },
};

// Dictionary<int, string>                  key      value
var dictionary = fruits.ToDictionary(x => x.Id, x => x.Name);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents