I want to get hex from a string like this:
Color c = new Color();
c.A = Int32.Parse("0x7F");
What's the right method for this ?
If the hex string isn't known till runtime, then something like this:
c.A = Convert.ToInt32("0x7F", 16);
Or as a literal if the value is known at compile time:
c.A = 0x7F;
With the Parse
method, check the overload which allows NumberStyles
. Reference http://msdn.microsoft.com/en-us/library/c09yxbyt.aspx
int bla = Int32.Parse("beef", NumberStyles.HexNumber);