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");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With