I want to have an enum that has a list of numeric values. How do I
achieve this?
Something like this ...
Public Enum AllowedNumbers
{
111,
222,
333,
444,
555
}
I can only have
Public Enum AllowedNumbers
{
AllowedValue1 = 111,
AllowedValue2 =222,
AllowedValue3 =333,
AllowedValue4 =444,
AllowedValue5 =555
}
Is there any way I can achieve this? 3 2072
>I want to have an enum that has a list of numeric values. How do I achieve this?
Why do you want an enum if you're not going to use the names? Wouldn't
an array work instead?
int[] allowedNumbers = {111,222,333,444,555};
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Hello Krish,
>Something like this ...
Public Enum AllowedNumbers { 111, 222, 333, 444, 555 }
It looks to me as if you're looking for a language feature similar to the
sets in Pascal.... that is not what enums are about. PowerCollections
( http://www.wintellect.com/PowerCollections.aspx) has an implementation of
Set<Tand Bag<Tclasses, and there are certainly other collection
libraries that do similar things, but there's no C# language feature for
this.
Oliver Sturm
-- http://www.sturmnet.org/blog
On Feb 9, 11:06 am, Mattias Sjögren <mattias.dont.want.s...@mvps.org>
wrote:
I want to have an enum that has a list of numeric values. How do I
achieve this?
Why do you want an enum if you're not going to use the names? Wouldn't
an array work instead?
int[] allowedNumbers = {111,222,333,444,555};
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.orghttp://www.msjogren.net/dotnet/|http://www.dotnetinterop.com
Please reply only to the newsgroup.
I dont think an array can work in my case.
What I need is to declare a variable of type enum and that enum can
have a list of numeric values.
Which means the variable can have one of the list of (numeric) values
ie my variable can have 111 or 222 or 333 or 555. How can we use array
in this case.
Thanks in advance ofr your help This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Glenn Venzke |
last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an
enum. Is it possible to pass the item name without the enum name in your
calling statement?
EXAMPLE:
public enum...
|
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: Craig Klementowski |
last post by:
All,
I've installed the VS 2005 Beta 1 and was trying to build our current
product. I get a compile error when enum value is specified with
classname::enumname::enumvalue. Seems the compiler...
|
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: Martin Engelhardt |
last post by:
Hi,
I want to use the following:
Class Test ...
Public Enum TestEnum as integer
Enum1 = 128
Enum2 = 256
End Enum
|
by: Steven Nagy |
last post by:
So I was needing some extra power from my enums and implemented the
typesafe enum pattern.
And it got me to thinking... why should I EVER use standard enums?
There's now a nice little code...
|
by: Zytan |
last post by:
Even with Option Strict On, which prevents an enum being set to an
Integer, you can still compare an enum to an integer without
complaint:
myEnum = 1 'fails
if (myEnum = 1) Then ... 'works
...
|
by: At_sea_with_C |
last post by:
Consider the following code:
#include <stdio.h>
#define SOMEVAL 1234
enum tree_types { PINE = 10, BIRCH, LARCH, OAK = 100, MAPLE, ELM, WILLOW };
void print_val(enum tree_types tree)
{...
|
by: tony_in_da_uk |
last post by:
*** I posted this on comp.lang.c++.moderated a couple days ago, and
got a near-flippant response from someone who clearly didn't take the
time to consider the import. I replied, and it's still not...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |