exclude item from array list c# -
i using asp.net 2013, want draw chart , give different color each point except e.g black, transparent , on.
it working fine there colors exclude.
var colours = typeof(system.drawing.color) .getproperties() .where(x => x.propertytype == typeof(system.drawing.color)) .select(x => x.name) .toarray(); random rcolor = new random(); foreach (var item in chart2.series[0].points) { item.color = system.drawing.color.fromname(colours[rcolor.next(0, colours.length)]); }
use color[] excludecolors
, except
:
color[] excludecolors = { color.black, ... }; var allcolors = var colours = typeof(system.drawing.color) .getproperties() .where(x => x.propertytype == typeof(system.drawing.color)) .select(x => system.drawing.color.fromname(x.name)); color[] usedcolors = allcolors.except(excludecolors).toarray(); foreach (var item in chart2.series[0].points) { color randomcolor = usedcolors[rcolor.next(usedcolors.length)]; item.color = randomcolor; }
since have initialize once should done in constructor(or can modify excludecolors
) , not in method.
Comments
Post a Comment