How to generate random color names in C#

后端 未结 15 1816
清酒与你
清酒与你 2020-11-29 21:57

I need to generate random color names e.g. \"Red\", \"White\" etc. How can I do it? I am able to generate random color like this:

Random randonGen = new Ran         


        
15条回答
  •  日久生厌
    2020-11-29 22:42

    To clear up the syntax errors in the original question, it's

    Color.FromRgb, and

    (Byte)random2.Next(255)

    converts the integer to a byte value needed by Color:

        Random random2 = new Random();
        public int nn = 0x128;
        public int ff = 0x512;
        Color randomColor = Color.FromRgb((Byte)random2.Next(nn, ff), (Byte)random2.Next(nn, ff), (Byte)random2.Next(nn, ff));
    

提交回复
热议问题