Generating a Random Color in C# - Printable Version +- BP Forums (https://bpforums.info) +-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55) +--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56) +---- Forum: C#.NET (Visual C# 2010/2008) (https://bpforums.info/forumdisplay.php?fid=20) +---- Thread: Generating a Random Color in C# (/showthread.php?tid=631) |
Generating a Random Color in C# - Macatone - 09-02-2012 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] Re: Generating a Random Color in C# - brandonio21 - 09-03-2012 Awesome! Thanks for sharing! Re: Generating a Random Color in C# - Macatone - 09-03-2012 brandonio21 Wrote:Awesome! Thanks for sharing!No problem! |