Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi

 

does anyone know of a variable scope that cannot be seen from another class, but can be used as an argument inside the same class?

 

for example - i tried this with Private

 

Public Class myClass

 Private Enum Example
    HI=1
    BYE=2
 End Enum


  Public Structure HeresTheProblem
     Dim Xample as Example
   End Structure

End Class

 

i want the Structure to be Public.. but it gives an error saying i cant make it Public while "Example" Is Private...

 

is there another scope for that?

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

  • Administrators
Posted

The enumeration needs to be public in this case - if the structure is public and it refered to a private data type how would calling code know how to use the enumeration?

It may helkp if you gave a bit more information on why you need this, there may be another means to implement it.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

You can use internal scope. But if you're going to compile all of your code into the same assembly (ie; not in a seperate .dll), then you might as well just make it public.

 

EDIT:

Actually, according to the definition on MSDN, protected scope may work. Your structure is within the same scope as your enum, and protected members are only accessible within the same class as it's declared, and derived classes.

 

Give protected a shot, see if it works. If not, internal or public are your only other alternatives.

Gamer extraordinaire. Programmer wannabe.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...