My idea was to switch between some colors, so I don’t have to use multiple pens but I can declare just one.
I’m not so sure to have understood exactly how enums work, please correct me:
type ColorType =
| Red = Color.Red
| Green = Color.Green
| Blue = Color.Blue
and I wish to use it in:
let p = new Pen(ColorType.[index])
g.DrawRectangle(p, 0, 0, 10, 10)
where index is an int variable (0 to 2) I’ll use to switch my colors. The problem is that I can’t declare that enum, Color is not accepted. Possible solutions?
To access the colors by index, you could put them in an array: