Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generating a Random Color in C#
#1
Here is a helpful code snippit that I converted to C# from Brandon's post in the Java forum.

This method returns a color with random red, green, and blue values.

Pastebin: http://pastebin.com/PceciHEE

[code2=csharp]//This method returns a color with random red, green, and blue values

public Color getRandomColor()
{
Random random = new Random();
return Color.FromArgb(random.Next(256), random.Next(256), random.Next(256));
}[/code2]


Messages In This Thread
Generating a Random Color in C# - by Macatone - 09-02-2012, 03:23 PM
Re: Generating a Random Color in C# - by Macatone - 09-03-2012, 10:31 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)