I'm generating some charts that need a hex string for the colors.
Example:
<dataseries name="ford" color="FF00FF" />
I'm creating these dynamically, so I would like to generate the hex code for each dataseries randomly.
What is the best way to do this?
Easiest way is to use String.Format
and use the hexadecimal format for the argument.
var random = new Random();
var color = String.Format("#{0:X6}", random.Next(0x1000000)); // = "#A197B9"