How to generate random color names in C#

后端 未结 15 1793
清酒与你
清酒与你 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:37

    private string getRandColor()
            {
                Random rnd = new Random();
                string hexOutput = String.Format("{0:X}", rnd.Next(0, 0xFFFFFF));
                while (hexOutput.Length < 6)
                    hexOutput = "0" + hexOutput;
                return "#" + hexOutput;
            }
    

提交回复
热议问题