What is it, what is it for and when do I use Friend?

7

Code sample:

Friend Const Public Frind
    
asked by anonymous 18.12.2014 / 12:11

1 answer

8

Friend is a modifier indicating that that member of a type (class, structure , enumeration, delegation, etc.) or the type itself will be visible throughout the assembly (usually a DLL). That is, any member of any type within that assembly can access it. It is a% more limited%. public allows the whole application to see that. In this case you control more access. It is a middle ground between public (only the type accesses itself) and private .

So all types that are friends can access this member. Who lives in the same block ( assembly / compilation drive) are friends. Even if you go distribute this assembly for third parties to use you know that the user application will not be able to access the public members, only what you compiled together.

Contrary to popular belief (they think it is Friend ) by default it is the visibility modifier used by the compiler.

For those who know C # is the same as private .

    
18.12.2014 / 12:41