CodeJoy CodeJoy - 2 months ago 7
C# Question

Why is System.Drawing.Color not an enum

Why is

System.Drawing.Color
a struct and
System.ConsoleColor
an enum ?

Answer

Because the console only supports a small set of colours, whereas System.Drawing models all possible 24-bit colours (32-bit with alpha). That's over 4 billion possible colours, which would be a big enum!

Here are the console colours:

enter image description here

There are 16 foreground, plus 16 background colours.

Note that in System.Drawing some colours are given names, but they're not an enum -- they're static fields, such as Color.Red and Color.Aquamarine.

The same is true of System.Windows.Media.Color (as used in WPF).