Get hexadecimal RGB value from System.Drawing.Color

Here’s a simple function that returns the hexadecimal RGB value of a System.Drawing.Color:

private string ToHexadecimalRgb(Color color)
{
 return color.ToArgb().ToString("X").Substring(2);
}

EDIT Apparently there is also a ColorTranslator with methods ToHtml and FromHtml.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>