Shared constants and enums.

wyrd

Senior Contributor
Joined
Aug 23, 2002
Messages
1,405
Location
California
I'm assuming from the error I'm getting from .NET that I can't create shared constants or enums? I find this rather puzzling and it just doesn't make sense to me. Is there any way to get around this? I suppose I could make a Public Shared Readonly Property... But that still doesn't get me past the Shared Enums. :(

While I'm on the topic of Constants and Enums, what's the recommended naming convention for those in .NET? Is it CAPS for Constants and PascalCase for Enums?
 
There is no need for constants to be shared, since the value of them is compiled in to your executable in any case.

I don't understand what you mean about shared enums. Enums are never instantiated, so I really don't know what you mean when you say you want them shared. Shared is a keyword you apply to methods to indicate you don't need an instance of the class to invoke them.

As far as naming conventions are concerned, I use what you said.
 
You can declare the public enum above your class and can be seen by the project.

If you want to see it from other projects in your solution, declare it inside its' own class then access it like this...

dim x as ProjectName.EnumsClassName.EnumsName
something = x.EnumValue
 
Divil:
Ahhh I see now. I went back and tried using the Enums/Constants inside a class without instantiating it (just using the Class name). I didn't expect Enums and Constants to work that way.

Robby:
Thanks for the idea.
 
Back
Top