The code for property initialization precedes your custom constructor body
New Productivity - Improving Syntax❘1011
Public Overrides Function ToString() As String
Return String.Format(“ID={0}, Customer={1}, Date={2}, #of Items={3}”, _ID, _CustomerName, _OrderDate, _Items.Count) End FunctionDespite the fact you can access the backing fi eld from code, it is not a good practice to do so. Use direct backing fi eld access only when it is really necessary — generally because of performance considerations.
Public Sub New(ByVal initialID As Integer)
ID = initialID
End Sub
‘ --- Other members omitted
End Class1012❘CHAPTER 22VISUAL BASIC 10.0 LANGUAGE IMPROVEMENTS
➤ You cannot initialize an auto - implemented property that is a member of an Interface or one that is marked MustOverride .
➤ When you declare an auto - implemented property as a member of a Structure , you can only initialize the auto - implemented property if it is marked as Shared .
➤ You want to add code for the Get or Set procedures.
➤ You need to extend the backing fi eld with attributes or comments.
Dim PrimesUnder50 As New List(Of Integer)
PrimesUnder50.Add(2)
PrimesUnder50.Add(3)