15

What would be the VB.NET equivalent of this code..

public virtual ICollection<Comment> Comments { get; set; }
AMadmanTriumphs
  • 4,888
  • 3
  • 28
  • 44
MoizNgp
  • 283
  • 1
  • 4
  • 17

3 Answers3

32

VB.NET (in version 10) has automatic properties just like 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
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
6
Public Overridable Property Comments() As ICollection(Of Comment)
PetPaulsen
  • 3,442
  • 2
  • 22
  • 33
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)