What’s it for, and when to use Friend?

Asked

Viewed 700 times

7

Code example:

Friend Const Public Frind

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 (in general a DLL). That is, any member of any type who is within this Assembly can access it. It’s a public more limited. The public allows the entire application to see that. In this case you control more access. It’s a middle between private (only the type itself accesses) and public.

So all the guys who are friends can access this member. Who lives on the same block (Assembly/compilation drive) are friends. Even though you will distribute this Assembly for third parties to use you know that the user application will not be able to access members Friend, just what you compiled together.

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.