I like the automatic .NET properties, in C # it is so easy to declare a readonly
property by declaring the set
section as private
as follows:
public String Name{ get; private set; }
But when I tried this in VB.NET, I was shocked that it is not supported, as mentioned here , and I have to write it like this:
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 is the difference between these ads in VB.NET
, which one is preferable and why?
Edit
Which one will affect compile time, runtime, or performance?
Amir ismail
source share