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: string5 Replies
i think ill need more information on what youre trying to achieve
your custom object, is that a class, a struct, or an anonymous type?
where id is the value of the enum. or the index in the enum where the value is?
the value being the name of the enum value? or the numeral value of the enum value as a string?
my custom object is a class
id: value of enum
value: the enum value
i.e. enum: Spring = 4,
Object id=4, value=Spring
ah, i see
give me a moment then
is something like this what you're looking for?
from just reading it yes is what i am looking for! thanks will test it out
thanks it was perfect!!