I Like .NET automatic properties, in C# it so easy to declare readonly
property by declaring its set
section as private
like this:
public String Name{ get; private set; }
But when I tried that in VB.NET I was shocked that it is not supported as mentioned here and I have to write it as follows:
Private _Name as String
Public ReadOnly Property Name as String
Get
return _Name
End Get
End Property
Or:
Private _Name as String
Public Property Name as String
Get
return _Name
End Get
Private Set(value as String)
_Name = value
End Set
End Property
What the difference between these declarations in VB.NET
, which one is preferred and Why?
Edit
Which one will affect compile time, runtime or performance at all?