How can Color.FromArgb take Int32 as parameter?

user1151923 picture user1151923 · Sep 11, 2014 · Viewed 15.3k times · Source

The Color.FromArgb method takes Int32 as a parameter. The value of Color.White is #FFFFFFFF as ARGB, which is 4.294.967.295 as decimal (way over int.MaxValue). What am I not understanding here? How can the method take int as a parameter if valid ARGB values are above the maximum value of an int?

Answer

Daws picture Daws · Sep 11, 2014

Unfortunately, since Color.FromArgb takes an int instead of a uint, you will need to use the unchecked keyword for colors that are greater than int.MaxValue.

var white = Color.FromArgb(unchecked((int)0xFFFFFFFF));