What does the 'friend' modifier do in VB.NET?
Why is it the default modifier for GUI components in Visual Studio?
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.
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With