S
steve bull
I am sure this is a really basic question but I don't see an easy way to do it.
I have an enum
public enum ColorType
{
red = 0,
green = 1,
blue = 2,
hue = 3,
saturation = 4,
brightness = 5
}
How can I associate a fixed value with each enum type? E.g. red is 255, hue=360 etc. Well, actually 255/fixedValue,
360/fixedValue etc.
I realize I could put these in a method with a switch statement and return the value but since the values are static or
at least only need to be calculated once at when the class is initialized it seems a waste of resources when I could end
up doing the calculation many times.
Is there a recomended way of doing something like this or at least a good way that doesn't involve lots of recasting of
the enum to ints.
Thanks,
Steve
I have an enum
public enum ColorType
{
red = 0,
green = 1,
blue = 2,
hue = 3,
saturation = 4,
brightness = 5
}
How can I associate a fixed value with each enum type? E.g. red is 255, hue=360 etc. Well, actually 255/fixedValue,
360/fixedValue etc.
I realize I could put these in a method with a switch statement and return the value but since the values are static or
at least only need to be calculated once at when the class is initialized it seems a waste of resources when I could end
up doing the calculation many times.
Is there a recomended way of doing something like this or at least a good way that doesn't involve lots of recasting of
the enum to ints.
Thanks,
Steve