NewIfNull

<Extension>
Public Function NewIfNull(Of T As Class)(ByRef value As T) As T

    If value Is Nothing Then
        value = GetType(T).CreateInstance
        Return value
    Else
        Return value
    End If

End Function
Example:
Private _person As Person

Public ReadOnly Property Person As Person
   Get
        Return _person.NewIfNull
   End Get
End Property

Description

Shortcut to create an object if it's null

Details

Double click on the code to select all.

 

;