Why is System.Drawing.Color
a struct and System.ConsoleColor
an enum ?
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:
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).
Because there are 16 well known colors for console, but 16777216 colors (plus 256 alpha levels for each) that can be used in general. Would you like to name all 4 billion of them and write code that then converts these enums back into actual RGBA values?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With