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

2019-02-16 06:35发布

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

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

2条回答
小情绪 Triste *
2楼-- · 2019-02-16 07:19

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

查看更多
ゆ 、 Hurt°
3楼-- · 2019-02-16 07:34

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

查看更多
登录 后发表回答