Why is the modifier set to Friend in Winforms?

2019-06-24 14:55发布

When adding a new control to the designer in Winforms, the modifier on the control is set to Friend, but the default modifier is Private (right clicking the property and resetting the modifier).

Does anyone know why?

Is there a setting to set the modifier to default (Private)?

2条回答
欢心
2楼-- · 2019-06-24 15:28

Are you sure it's showing as friend? I tried to reproduce the same here but it's always showing as private. Am using Visual Studio 2008.

After lot of googling, I eventually found some answers and they are right here on SO:

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

Set a project default for VB.NET projects so that the default Modifiers property for controls is Private

查看更多
可以哭但决不认输i
3楼-- · 2019-06-24 15:38

This is just the default which was chosen by the VB.Net IDE team. While I don't know the reason behind the decision my guess is that it was to maintain a compatible design experience with VB6.

There is no way that I know of to override this value

查看更多
登录 后发表回答