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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -