Search code examples
c#colorsargb

How can Color.FromArgb take Int32 as parameter?


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?


Solution

  • 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));