CodeJoy CodeJoy - 1 year ago 118
C# Question

Why is System.Drawing.Color not an enum

Why is

a struct and
an enum ?

Answer Source

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).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download