I just wondered if VB.Net has a shorthand equivalent for this type of C #, including setter private :
private
public string Test { get; private set; }
Can someone please tell me the shortest way to achieve this in VB.Net?
Sorry, this is not possible in VB.NET:
Authorized properties are convenient and support many programming scenarios. However, there are situations in which you cannot use automatically realized property and instead use standard or advanced property syntax.You must use the extended property definition syntax if you want to do one of the following:...Create properties that are WriteOnly or ReadOnly....
Authorized properties are convenient and support many programming scenarios. However, there are situations in which you cannot use automatically realized property and instead use standard or advanced property syntax.
You must use the extended property definition syntax if you want to do one of the following:
Unfortunately, you cannot use different options for auto accessories in VB.NET. You must manually write the property code.
Like this:
Private _test As String Public Property Test() As String Get Return _test End Get Private Set(ByVal Value As String) _test = Value End Set End Property
There is no alternative.