I am new to VB.Net but have a strong background in C# so it isn't that hard to learn it. One issue I have noticed is how enums work. In C# a public enum is considered static, for example:
public class foo
{
public enum bar
{
enum1,
enum2 //etc...
}
}
If I want to access this enum I would simply do something like:
int x = (int)foo.bar.enum1
And if I were to instantiate an object of foo, that object would not contain the base enum:
foo test = new foo();
int x = (int)test.bar.enum1; //compiler would melt down, the class object doesn't have a bar property (since its static)
In VB.Net this doesn't seem to be the case. I have 15 enums in a project I am working on and they seem to be overcrowding my properties list when they don't need to be there in the first place. What I am trying to find out is if it is possible to hide these. I tried declaring them as 'Shared' (the Vb.Net equivalent of static in C#) but this throws a compiler exception. Marking them as private/protected also does me no good, since some public properties are enum types.
Dim test As foo
test = new foo()
x = test.bar.enum1 //I dont want this to be possible! It overcrowds the properties list and makes my co-workers get headaches looking through it
x = foo.bar.enum1 //This works, but I want this to be the only way to access the enum