I would like to have a bearing on the alpha value. So I changed the method. With that I can use the following syntax:myObject.Foreground = ParseColor(”#AAFF0000″);Here is the changed method:public static Color ParseColor(string value) { value = value.Replace(”#”, “”); Int32 v = Int32.Parse(value, System.Globalization.NumberStyles.HexNumber); return new Color() { A = Convert.ToByte((v >> 32) & 255), R = Convert.ToByte((v >> 16) & 255), G = Convert.ToByte((v >> & 255), B = Convert.ToByte((v >> 0) & 255), };}
July 25th, 2009 at 4:58 am
I would like to have a bearing on the alpha value. So I changed the method. With that I can use the following syntax:myObject.Foreground = ParseColor(”#AAFF0000″);Here is the changed method:public static Color ParseColor(string value) { value = value.Replace(”#”, “”); Int32 v = Int32.Parse(value, System.Globalization.NumberStyles.HexNumber); return new Color() { A = Convert.ToByte((v >> 32) & 255), R = Convert.ToByte((v >> 16) & 255), G = Convert.ToByte((v >>
& 255), B = Convert.ToByte((v >> 0) & 255), };}
July 25th, 2009 at 4:59 am
Sorry, but there is no possability for “code design”.
July 26th, 2009 at 10:28 am
[...] Convert string to Color (Corey Schuman) [...]
September 5th, 2009 at 12:00 pm
Thanks this was perfect..nice and simple