.net - Enums of colors -
my idea switch between colors, don't have use multiple pens can declare one.
i'm not sure have understood how enums work, please correct me:
type colortype = | red = color.red | green = color.green | blue = color.blue
and wish use in:
let p = new pen(colortype.[index]) g.drawrectangle(p, 0, 0, 10, 10)
where index int variable (0 2) i'll use switch colors. problem can't declare enum, color not accepted. possible solutions?
to access colors index, put them in array:
let colors = [| color.red color.green color.blue |] let p = new pen(colors.[index]) g.drawrectangle(p, 0, 0, 10, 10)
Comments
Post a Comment