Testing
- Posted using BlogPress from my iPhone
Location:Granberry St,Houston,United States
HowManyOfMe.com | ||
|
public List<keyvaluepair<k,>> BuildListFromEnum<k,>(Type type)
{
var list = new List<keyvaluepair<k,>>();
foreach (K key in Enum.GetValues(type))
{
V name = (V)Convert.ChangeType(Enum.GetName(type, key), typeof(V));
list.Add(new KeyValuePair((K)key, name));
}
return list;
}
var statuses = from status in statusList select new NameValue(status.Value, status.Key);
[Serializable]
public class NameValue
{
public N Name { get; set; }
public V Value { get; set; }
public NameValue() { }
public NameValue(N name, V value)
{
Name = name;
Value = value;
}
}