[VS2005] HEX to RGB

Changing the Hex value of a color to RGB format can be done using the following example.

if (HexColor.Replace(“#”, “”).Length == 6)
{
byte r, g, b;
HexColor = HexColor.Replace(“#”, “”);

r = Convert.ToByte(HexColor.Substring(0, 2), 16);
g = Convert.ToByte(HexColor.Substring(2, 2), 16);
b = Convert.ToByte(HexColor.Substring(4, 2), 16);

series.Color = Color.FromArgb(r, g, b);
}
else
throw new Exception(“Invalid HEX value”);