Re: enum base class
- From: "Jure Bogataj" <jure.bogataj@xxxxxxxxxxxx>
- Date: Tue, 4 Sep 2007 09:04:43 +0200
Actually, members of the enumeration are declared so only one bit of 32-bit
unsigned int is set.
e.g.
public enum MyEnum1
{
enumValue1 = 0x00000001,
enumValue2 = 0x00000002,
enumValue3 = 0x00000004,
enumValue4 = 0x00000008,
enumValue5 = 0x00000010,
enumValue6 = 0x00000020,
}
Then I check all enumeration / their values the same way. I just have many
enumerations for code clarity?
Best regards,
Jure
"Doug Semler" <dougsemler@xxxxxxxxx> wrote in message
news:uXCQZUn7HHA.4584@xxxxxxxxxxxxxxxxxxxxxxx
"Jure Bogataj" <jure.bogataj@xxxxxxxxxxxx> wrote in message
news:eBDU1Wj7HHA.2752@xxxxxxxxxxxxxxxxxxxxxxx
Hi all!
I have two enumerations:
public enum MyEnum1
and
public enum MyEnum2
I want to create function that accepts parameter as member of either
enumeration. Is this at all possible?
Something like:
public void MyFunc(EnumBase myEnumValue)
{
}
Or is there some other way to accomplish this. Actually I have arround 10
enums and I don't want to create separate functions since the logic is
the same?
Maybe I can accomplish something through System.Enum?
You could cast all of the enums to int and declare the function with the
int parameter.
However, I question a design that requires 10 different enumerations
which, when cast, provide the same values for a particular functionality.
If you're not examining the bits but need to keep the type, you can always
pass it to your function as an object:
void myFunc(object o)
{
Console.WriteLine(Enum.Format(o.GetType(), o, "x"));
}
--
Doug Semler, MCPD
a.a. #705, BAAWA. EAC Guardian of the Horn of the IPU (pbuhh).
The answer is 42; DNRC o-
Gur Hfrarg unf orpbzr fb shyy bs penc gurfr qnlf, abbar rira
erpbtavmrf fvzcyr guvatf yvxr ebg13 nalzber. Fnq, vfa'g vg?
.
- Follow-Ups:
- Re: enum base class
- From: Doug Semler
- Re: enum base class
- References:
- enum base class
- From: Jure Bogataj
- Re: enum base class
- From: Doug Semler
- enum base class
- Prev by Date: Re: WindowsCe & Autogenerated code
- Next by Date: Re: Replace a flag field for other value in grid
- Previous by thread: Re: enum base class
- Next by thread: Re: enum base class
- Index(es):
Relevant Pages
|