A few months ago I wrote this code because it was the only way I could do this (by learning C #), well. How would you do that? Is the uncheckedright way to do this?
unchecked
unchecked //FromArgb takes a 32 bit value, though says it signed. Which colors shouldn't be. { _EditControl.BackColor = System.Drawing.Color.FromArgb((int)0xFFCCCCCC); }
You can break up the int components and use the overload FromArgb()that takes them separately:
FromArgb()
System.Drawing.Color.FromArgb( 0xFF, 0xCC, 0xCC, 0xCC);
It accepts a signed int b / c, this refers to the time when VB.NET had no unsigned values. Therefore, to maintain compatibility between C # and VB.NET, all BCL libraries use signed values, even if they have no logical meaning.
:
public static Color ToColor(this uint argb) { return Color.FromArgb(unchecked((int)argb)); } public static Color ToColor(this int argb) { return Color.FromArgb(argb); }
0xff112233.ToColor(); 0x7f112233.ToColor();
, (, 0v12345678) - .