How to convert Hexadecimal #FFFFFF to System.Drawing.Color [duplicate]
Possible Duplicate:
How to get Color from Hex color code using .NET?
I want to convert a string like #FFFFFF
to System.Drawing.Color
. How do you do that?
string hex = "#FFFFFF";
Color _color = System.Drawing.ColorTranslator.FromHtml(hex);
Note: the hash is important!
You can do
var color = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
Or this (you will need the System.Windows.Media
namespace)
var color = (Color)ColorConverter.ConvertFromString("#FFFFFF");