I have a list:
public class tmp
{
public int Id;
public string Name;
public string LName;
public decimal Index;
}
List<tmp> lst = GetSomeData();
I want to convert this list to HashTable, and I want to specify Key and Value in Extension Method Argument. For example I may want to Key=Id and Value=Index or Key = Id + Index and Value = Name + LName. How can I do this?
You can use
ToDictionarymethod:You don’t need to use
Hashtablewhich comes from .NET 1.1,Dictionaryis more type-safe.