i have this list of colors in a wpf application.
what i want is to random choose a color each time i call the funtion but i dont want that a one color be chosen more than on time.
this is my code that not doing what i want.
var polyline = new MapPolyline();
polyline.Stroke = GetRandomPolylineColor();
private Brush GetRandomPolylineColor()
{
var brushes = new Brush[]
{ Brushes.Blue,
Brushes.Black,
Brushes.Red,
Brushes.Brown,
Brushes.Green,
Brushes.HotPink,
Brushes.Khaki,
Brushes.IndianRed,
Brushes.LimeGreen,
Brushes.Orange
};
var rnd = new Random();
return brushes[rnd.Next(brushes.Length)];
}
Aucun commentaire:
Enregistrer un commentaire