在Windows窗体项目时,为什么设计者在默认情况下使用朋友WithEvents就
属性在VB.NET和私人
那些在C#?
In Windows Forms projects, why does the designer by default use the Friend WithEvents
attributes in VB.NET and private
ones in C#?
例如,在 form.designer
文件:
的.cs
private Label Label1;
的.vb
Friend WithEvents Label1 as Label;
有关 WithEvents就
,它是多了还是不太清楚(使用手柄
,很明显)。但是,为什么的朋友的在VB和私人的在C#?
For WithEvents
, it is more or less clear (for using Handles
, apparently). But why Friend in VB and private in C#?
朋友WithEvents就
用于兼容旧的Visual Basic code,其中正常对照的其中载有它的形式之外使用。
不同的是,在C#中有没有那么必要。
Friend WithEvents
is used for compatibility with older Visual Basic code, where normally a control was used outside the form which contained it.
Differently, in C# there is not that necessity.
私人
是一个更好的解决方案,新的code。
private
is a better solution, for new code.