Today, we have a super-simple tip on how to translate a Color object to HTML (hex) without writing the translation code yourself. If you search the Internet, you'll see something pretty long and un-understandable at first glance and, probably, not even at second or third glance.

You don't need to do this.

The .NET framework already gives you a way to create the hex-equivalent of a Color.

To Hex

System.Drawing.Color color = System.Drawing.Color.FromArgb(0, 255, 0);

string html = System.Drawing.ColorTranslator.ToHtml(color);

And vice versa

System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(html);