这段代码的VB.NET等价物是什么..
public virtual ICollection<Comment> Comments { get; set; }
答案 0 :(得分:29)
VB.NET(在版本10中)具有与C#类似的自动属性。等效语法如下:
Public Overridable Property Comments() As ICollection(Of Comment)
自动转换器倾向于产生比必要更冗长的语法。您可以根据需要进行扩展,但除非您使用旧版本的编译器,否则不一定非必要:
Private m_Comments As ICollection(Of Comment)
Public Overridable Property Comments() As ICollection(Of Comment)
Get
Return m_Comments
End Get
Set(ByVal value As ICollection(Of Comment))
m_Comments = value
End Set
End Property
答案 1 :(得分:5)
Public Overridable Property Comments() As ICollection(Of Comment)
答案 2 :(得分:0)
Public Overridable Property Comments() As ICollection(Of Comment)
Get
Return m_Comments
End Get
Set
m_Comments = Value
End Set
End Property
Private Overridable m_Comments As ICollection(Of Comment)