简体   繁体   English

VB.NET等效于此代码

[英]VB.NET Equivalent of this code

VB.NET的等效代码是什么。

public virtual ICollection<Comment> Comments { get; set; }

VB.NET (in version 10) has automatic properties just like C#. VB.NET(在版本10中)具有自动属性,就像C#。 The equivalent syntax is as follows: 等效语法如下:

Public Overridable Property Comments() As ICollection(Of Comment)

The automatic converters tend to produce syntax that is more verbose than necessary. 自动转换器倾向于产生比必要的更为冗长的语法。 You can expand it if you want, but it's not strictly necessary unless you're using an older version of the compiler: 您可以根据需要对其进行扩展,但是除非您使用的是较早版本的编译器,否则这并不是绝对必要的:

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
Public Overridable Property Comments() As ICollection(Of Comment)
 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM