Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.NET: what does the 'friend' modifier do?

What does the 'friend' modifier do in VB.NET?

Why is it the default modifier for GUI components in Visual Studio?

like image 405
CJ7 Avatar asked May 05 '10 11:05

CJ7


People also ask

What does friend mean in VB net?

friend in VB.Net is the same as internal in C#, it means that it can be accessed anywhere in the same assembly, but not from other assemblies.

Is Friend an access modifier?

The Protected Friend keyword combination is a member access modifier. It confers both Friend access and Protected access on the declared elements, so they are accessible from anywhere in the same assembly, from their own class, and from derived classes.

What is the difference between friend and protected friend in VB net?

Protected Friend is what you need for building your own object libraries. Friend is just for difficult code situations where assembly wide access is really required.


1 Answers

friend in VB.Net is the same as internal in C#, it means that it can be accessed anywhere in the same assembly, but not from other assemblies.

I think it's a sensible default since I would say that normally one assembly should not be using another assembly's GUI controls (unless it's a class library or similar that is built for the purpose).

like image 114
Hans Olsson Avatar answered Nov 19 '22 23:11

Hans Olsson