Link to home
Start Free TrialLog in
Avatar of Fred Goodwin
Fred GoodwinFlag for United States of America

asked on

Simple Namespace Question

So I have a Namespace setup like this

Namespace 1

     Public Class A
         ...
     End Class

     Public Class B
         ...
     End Class

     Public Class C
         ...
     End Class

     Public Class D
         ...
     End Class

End Namespace

What I would like to do is only expose A,B and C and Make D only accessable to classes within the namespace.  I want to use D as a support class for A,B, and C but not allow it to be called directly.  

Any help would be great.  Thanks
Avatar of eventprostrategies
eventprostrategies

Hmm ... good question.  Not entirely sure.

Not a final answer, but -- a workaround for the moment is to make the class private and stick it into each of the public classes.  Obviously not a final answer -- I'll be interested to see if it's doable, how you want it -- but, you can always stick a private class into another class (as a helper class or whatnot -- just don't expose methods that require the class as a parameter or return type).

Non-public classes have to be within other classes ... and I don't know how Public Classes can be picky/choosy over who can call them.
Try declaring Class D as Protected instead of Public.

http://www.startvbdotnet.com/language/datatypes.aspx

This site has a listing of the access specifiers and what they do.
I tried that and got a design-time error -- Protected types can only be declared inside of a class.

Define D as a protected class within superclass S

Let A, B, C Inherit from superclass S
ASKER CERTIFIED SOLUTION
Avatar of Jens Fiederer
Jens Fiederer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Fred Goodwin

ASKER

Looks like this works best for what I was trying to do.  The SuperClass idea works but still opens me up more than I would like.

Thanks for the help.