从C#中的Brushes集合中选择随机画笔的最佳方法是什么?

SBu*_*ris 6 c# collections select brush

从C#中的System.Drawing.Brushes集合中选择随机画笔的最佳方法是什么?

jjx*_*tra 13

如果你只想要一个随机颜色的实心画笔,你可以试试这个:

    Random r = new Random();
    int red = r.Next(0, byte.MaxValue + 1);
    int green = r.Next(0, byte.MaxValue + 1);
    int blue = r.Next(0, byte.MaxValue + 1);
    System.Drawing.Brush brush = new System.Drawing.SolidBrush(Color.FromArgb(red, green, blue));
Run Code Online (Sandbox Code Playgroud)