On this page

From html colors to .NET colors and back



The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 8
This Year: 0
This Month: 0
This Week: 0
Comments: 5

Sign In
Pick a theme:

# Tuesday, 16 January 2007
Tuesday, 16 January 2007 10:22:05 (GMT Standard Time, UTC+00:00) ( .net )

While exploring the deeps of .NET I found this wonderful class....
The System.Drawing.ColorTranslator class.
If I'd only known earlier.... This class has a static method that converts a System.Drawing.Color to the Html notation of that color,
and another to convert it back.

These methods are respectively:
string colorHtml = System.Drawing.ColorTranslator.ToHtml(Color.LightBlue);
System.Drawing.Color netColor = System.Drawing.ColorTranslator.FromHtml("#F3E0F7");

As I've said before, If I'd only known earlier.... These nice secrets of .NET can be very usefull....
But you have to know about them. Otherwise you start making these kind of functions yourself.