Nested Enums?

Jaco

Regular
Joined
Mar 10, 2004
JDYoder said:
I don't suppose this is possible in VB.NET, is it?

No, but I suspect that what you might want is just to nest classes to get the desired qualification:

e.g.,
class A
class B
enum C
...

So that the enum is referenced as A.B.C ... ??
 

JDYoder

Centurion
Joined
Nov 18, 2003
>> An enum is just a list of consts, why would you need to nest them?

For easy categorizing.



Jaco -- Yeah, for something like that. I wondered if I'd have to do it that way with classes, so I'll just do that. Thanks.
 

Joe Mamma

Senior Contributor
Joined
Mar 1, 2004
Location
Washington DC
JDYoder said:
>> An enum is just a list of consts, why would you need to nest them?

For easy categorizing.
What are you trying to model? Sets of enums? Sets are one thing missing from the .Net framework but there is an implementation from preilly's C# cookbook here. Look at chapter 10. recipe 10.8
 

SkeeZoe

Newcomer
Joined
Jul 30, 2012
Did you mean retrieving the full nested string name of an enum (e.g. System.Tools.Enums)?

Try This:

Dim x as System.Tools.SomeEnums = System.Tools.SomeEnums.FartKnocker
Dim y as String = GetType(x).ToString

Where:

Enum SomeEnums
FartKnocker = 1
JabberJaw = 2
None = 0
End Enum
 
Top Bottom