The error itself is self-evident. it tells you that the switch expression must be one of the following types: sbyte, byte, short, ushort, int, uint, long, ulong, char, string. or since the C # language specification offers
only one user-defined implicit conversion (ยง6.4) must exist from the switch expression type: one of the following possible control types: sbyte, byte, short, ushort, int, uint, long, ulong, char, a string or a type with a null value corresponding to one of these types.
And you can see that BackColor returns your type here, and it does not satisfy any of the above rules, therefore, an error.
you can do it like this
switch (btn.BackColor.Name) { case "Green": break; case "Red": break; case "Gray": break; }
Ehsan
source share