wyrd Posted November 23, 2002 Posted November 23, 2002 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? Quote Gamer extraordinaire. Programmer wannabe.
*Gurus* divil Posted November 23, 2002 *Gurus* Posted November 23, 2002 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. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Moderators Robby Posted November 23, 2002 Moderators Posted November 23, 2002 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 Quote Visit...Bassic Software
wyrd Posted November 23, 2002 Author Posted November 23, 2002 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. Quote Gamer extraordinaire. Programmer wannabe.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.