In Windows Forms projects, why does the designer by default use the Friend WithEvents attributes in VB.NET and private ones in C#?
For example, in a form.designer. file:
.cs
private Label Label1;
.vb
Friend WithEvents Label1 as Label;
For WithEvents, it is more or less clear (for using Handles, apparently). But why Friend in Visual Basic and private in C#?
Friendis used for compatibility with older Visual Basic code, where normally a control was used outside the form which contained it.In C# there isn’t that necessity.
privateis a better solution, for new code.