defining a const color object

  • Thread starter Thread starter Claire
  • Start date Start date
C

Claire

The following code raises an error.
"The expression being assigned to 'CeMate.frmMain.BACKCOLOR' must be
constant"

private const Color BACKCOLOR = Color.AliceBlue;

I want to define some const colors. How do I do this please.
 
Claire said:
The following code raises an error.
"The expression being assigned to 'CeMate.frmMain.BACKCOLOR' must be
constant"

private const Color BACKCOLOR = Color.AliceBlue;

I want to define some const colors. How do I do this please.

Just use static readonly instead. Colors can't be const, as only the
following types are valid for constant expressions:

sbyte, byte, short, ushort, int, uint, long, ulong, char, float,
double, decimal, bool, string, any enumeration type, or the null type
 
Back
Top