C#C
C#2y ago
hugi

How do I cast my enum to a list of custom object?

(yes I am aware of dictionary, but I want to use custom object in this case)
When I did it to dictionary I was doing the following:
var dict = Enum.GetValues(typeof(T)) .Cast<T>().ToDictionary(t => (int)(object)t, t => getEnumString(t.ToString()));
But I wasn't able to figure out how to change that to cast to custom object instead, or do I just convert the dict above into custom object after? Is there a way to not do that?
custom object myObject: id: number, value: string
Was this page helpful?