PDA

Click to See Complete Forum and Search --> : *resolved* dumb dumb dumb question - protected


MrPolite
Oct 18th, 2002, 03:51 PM
I know this has been asked 1010100100202039028 times, but I DONT GET IT!!!!! :(

What's the difference between these two:


Public Class A
Protected Class B

End Class
End Class
and

Public Class A
Private Class B

End Class
End Class



I dont know what Friend, Protected, or Protected Friend means :( MSDN doesnt help neither, maybe I'm too dumb or whatever, but someone plz explain this :D

Edneeis
Oct 18th, 2002, 04:08 PM
Friend is Public to anything in the same project otherwise it is treated as Private. Protected is somewhat like that only instead of Public to the Project it is Public to the class and any class derived from that class.

hellswraith
Oct 18th, 2002, 05:08 PM
From a book:
Public - Can be accessed from anywhere.

Private - Can be accessed only by members within the type that defines it.

Friend - Can be accessed form all types within the assembly, but not from outside the assembly.

Protected - Can be accessed only by members within the type that defines it or types that inherit from that type.

Protected Friend - Can be accessed from all types within the assembly or from types inheriting from the owning type. This is the union of Protected and Friend access.

MrPolite
Oct 18th, 2002, 09:17 PM
ok, kinda get it :D
just what does it mean when it says "within the assembly"? what's an assembly?

Edneeis
Oct 18th, 2002, 09:48 PM
An assembly is an exe or dll whatever the project basically is.

MrPolite
Oct 18th, 2002, 11:41 PM
Originally posted by Edneeis
An assembly is an exe or dll whatever the project basically is.
hmm, so if you have two projects in one solution, and you have a Friend variable, it an be only accessed in one of the project?

Edneeis
Oct 19th, 2002, 12:19 AM
Yes just like groups in VB6, in fact Friend isn't new with .NET we had it in VB6, too.