Hide a class

  • Thread starter Thread starter Johnny Emde Jensen
  • Start date Start date
J

Johnny Emde Jensen

Hello

I have made a class/class environment

It looks like this

Environment
User
Computer
Network
Software

The User, Computer, Network and Software are also classes.

When I instansiate Environment (dim objEnv as Enviornment = New Environment)
the objEnv automatically instansiate user, computer, network and software.

In my code i like to hide the User, Computer, Network and Software so that
these can't be instasiated outside the Environment Class

Is it possible?

Kind regards
Johnny E Jensen
 
Yes, it's possible. How you do it depends on how you want it to work.

You can make the constructors in the classes 'internal', that way they
can only be created from within the same assembly. They can still be
used from outside the assembly though.

You can declare the classes inside the Environment class and make them
'private'. That way they are only usable inside the Environment class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top