473,387 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

defining a const color object

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.
Nov 16 '05 #1
1 3659
Claire <bl****@blahhhhh.com> wrote:
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

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Matt Garman | last post by:
I'd like to create a "custom output facility". In other words, I want an object whose use is similar to std::cout/std::cerr, but offers more flexibility. Instead of simply writing the parameter...
29
by: Joe | last post by:
This is a very basic question, but why can't I do the following ? class schedule { private: static const string mScheduleFile = "schedule.txt"; .... }
10
by: Joe Laughlin | last post by:
I'm sure there's a fairly easy answer for this... but how can I define a new type with range checking? Example: I want to define a new type that's like a double, except that you can only give...
2
by: jut_bit_zx | last post by:
Consider the following code: #include <iostream> #include <map> using namespace std; typedef struct tagPOINT { tagPOINT(); bool operator == (const tagPOINT& point);
0
by: Ben Cox | last post by:
I need help in defining the C++ tapi interface in C#. Any help with this would be appreciated. #ifndef __ITAMMediaFormat_INTERFACE_DEFINED__ #define __ITAMMediaFormat_INTERFACE_DEFINED__ ...
0
by: Nataraj Narayana via DotNetMonster.com | last post by:
I have reqirements of defining prototypes for C++ dll function in C# so that I can use p/invoke method to access the dll's functions. Can anyone please suggest how to write prototypes in C# for...
5
by: chrisstankevitz | last post by:
Why does this code only compile if GLOBAL_IN_STRUCT is defined? It creates a templated class C<T> and defines a global operator* that takes a C<T> on the LHS and a T on the RHS. In the...
4
by: Hans | last post by:
Hi, I want to define a couple of constant strings, like in C: #define mystring "This is my string" or using a const char construction. Is this really not possible in Python? Hans
6
by: alan | last post by:
I'm creating a sort-of "wrapper" class which (partly) acts like a variable. Something like: template<class t> class cell{ t curval; public: /*public for debugging only - will be private in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.