Shared constants and enums.

wyrd

Well-known member
Joined
Aug 23, 2002
Messages
1,408
Location
California
Im assuming from the error Im getting from .NET that I cant create shared constants or enums? I find this rather puzzling and it just doesnt 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 doesnt get me past the Shared Enums. :(

While Im on the topic of Constants and Enums, whats 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 dont understand what you mean about shared enums. Enums are never instantiated, so I really dont know what you mean when you say you want them shared. Shared is a keyword you apply to methods to indicate you dont 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 didnt expect Enums and Constants to work that way.

Robby:
Thanks for the idea.
 
Back
Top