Why System.Drawing.Color does not list

Why is System.Drawing.Color a struct and System.ConsoleColor a enumeration ?

+5
source share
2 answers

Since the console only supports a small set of colors, while System.Drawing models all possible 24-bit colors (32-bit with alpha). This is more than 4 billion possible colors, which would be a great listing!

Here are the console colors:

enter image description here

There are 16 front and 16 background colors.

Note that in System.Drawing some colors are named , but they are not enumerated — they are static fields such as Color.Red and Color.Aquamarine .

The same applies to System.Windows.Media.Color (as used in WPF).

+7
source

Since there are 16 well-known colors for the console, but 16777216 colors (plus 256 alpha levels for each) that can be used as a whole. Do you want to name all 4 billion of them and write code that then converts these enumerations into actual RGBA values?

+1
source

Source: https://habr.com/ru/post/1257899/


All Articles