The problem is you can't use a Color
in a switch
statement. It must be one of the following types, a nullable version of one of the types, or or convertible to one of these types: sbyte
, byte
, short
, ushort
, int
, uint
, long
, ulong
, char
, string
From the C# language spec, 8.7.2:
• Otherwise, exactly one user-defined implicit conversion (§6.4) must exist from the type of the switch expression to one of the following possible governing types: sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or, a nullable type corresponding to one of those types.
In your case, you could work around this by using strings, or just using a set of if
/else
statements.