Hello NG,
I would like to define a Color Enum like:
public enum MyColorEnum
{
Color1 = Color.Red,
Color2 = Color.Gren,
....
}
Unfortunately this doesn't work.
Is it possible to do some thing like this, and if yes, how?
Thanks for help!
Regards
Rainer 4 25955
Rainer,
Enumeration values can only use integral types as a base (int, long,
byte, etc, etc), not structures or classes (like the Color structure).
What you could do is create a static class, exposing static read-only
properties/fields which you would set in the static constructor. This would
give you a class with the same semantics as an enumeration.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Rainer Queck" <Ra**********@nomail.nomail.comwrote in message
news:O5**************@TK2MSFTNGP03.phx.gbl...
Hello NG,
I would like to define a Color Enum like:
public enum MyColorEnum
{
Color1 = Color.Red,
Color2 = Color.Gren,
....
}
Unfortunately this doesn't work.
Is it possible to do some thing like this, and if yes, how?
Thanks for help!
Regards
Rainer
Rainer,
Enumeration values can only use integral types as a base (int, long,
byte, etc, etc), not structures or classes (like the Color structure).
What you could do is create a static class, exposing static read-only
properties/fields which you would set in the static constructor. This would
give you a class with the same semantics as an enumeration.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Rainer Queck" <Ra**********@nomail.nomail.comwrote in message
news:O5**************@TK2MSFTNGP03.phx.gbl...
Hello NG,
I would like to define a Color Enum like:
public enum MyColorEnum
{
Color1 = Color.Red,
Color2 = Color.Gren,
....
}
Unfortunately this doesn't work.
Is it possible to do some thing like this, and if yes, how?
Thanks for help!
Regards
Rainer
Hello Nicholas,
Enumeration values can only use integral types as a base (int, long,
byte, etc, etc), not structures or classes (like the Color structure).
That is what I thought, but I was hoping for a workaround....
What you could do is create a static class, exposing static read-only
properties/fields which you would set in the static constructor. This
would
give you a class with the same semantics as an enumeration.
A workaround like this :-)
Thanks for the hint!
Regards
Rainer This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Imran |
last post by:
Hello All
I have a enum decla like this
enum Days // Declare enum type Days
{
saturday, // saturday = 0 by default
sunday = 0, // sunday = 0 as well
monday, ...
|
by: Nikhil Patel |
last post by:
Hi all,
I am a VB6 programmer and learning C#. I am currently reading a chapter
on types. I have question regarding enums. Why do we need to convert enum
members to the value that they represent?...
|
by: Andreas Huber |
last post by:
Hi there
Spending half an hour searching through the archive I haven't found a
rationale for the following behavior.
using System;
// note the missing Flags attribute
enum Color
{
|
by: Michael C |
last post by:
If a class inherits from another class, say Form inherits from control, then
I can assign the Form to a variable of type Control without needing an
explicit conversion, eg
Form1 f = new Form1();...
|
by: ad |
last post by:
I cant to write a function to manage the font color of my web.
The function is like:
using System.Drawing;
public static string Font(string input, Color my)
{
string sRV = "";
sRV = "<font...
|
by: VJ |
last post by:
I have one VB.NET project, that outputs a "Mycomapny.exe" everytime I do a
build. But I need it to output 4 different executables everytime I build.
How do I archive this. I am looking at the...
|
by: Don |
last post by:
How do I get an Enum's type using only the Enum name?
e.g.
Dim enumType as System.Type
Dim enumName as String = "MyEnum"
enumType = ???(enumName)
|
by: Ben Finney |
last post by:
Howdy all,
I've uploaded enum 0.3 to the Cheeseshop.
<URL:http://cheeseshop.python.org/pypi/enum/>
Enumerations are now sequences, iterable (as before) *and* indexable::
>>> from enum...
|
by: msjonathan |
last post by:
Hi,
I am making a program with multiple grids, the user can drag&drop rows between Grids.
For visualizing this nice and easy I give each row in a grid an other color.
For the moment I store the...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |