public variable or friend?

D

D.

Hi,

i come from classic asp and i'm a little confused with variable declaration
in VB.
I read: "A Public variable is accessible from any place within the module it
was declared or other applications which refer to the application where it
was declared".

What does mean 'application'? Is that all the files within an
applicationroot?
And is a module an aspx-file?

So if i declare a public variable, is it correct to say:
- that var. is accessible from any place in the aspx file
- but not from another aspx file in the same application

And finally: what does mean "or other applications which refer to the
application where it was declared"?

Thanks
D
 
K

Karl Seguin [MVP]

Bad wording...

public is globally accessible to any piece of code. By "application" they
mean "assemblies". So if someone adds an reference to your assembly, they'll
be able to access any public variables. Your assumption is wrong. a public
var is accessible to _everything_ including classes in your own assembly (a
page is just a class), and classes in other assemblies.

A friend is accessible to any class within your assembly, but not outside
assemblies.

private is your class only

protected is your class or child classes (inheritance)

Karl
 

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

Top