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

痞子三分冷 提交于 2019-11-30 22:06:52

问题


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

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


回答1:


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).




回答2:


Friend is available in VB: The Friend (Visual Basic) keyword in the declaration statement specifies that the elements are accessible from within the same assembly,
From here

I believe the c# version is internal



来源:https://stackoverflow.com/questions/2772815/vb-net-what-does-the-friend-modifier-do

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!