Does VB.NET have the equivalent of a C # auto property with a special access specifier?

I just wondered if VB.Net has a shorthand equivalent for this type of C #, including setter private :

 public string Test { get; private set; } 

Can someone please tell me the shortest way to achieve this in VB.Net?

+4
source share
3 answers

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.
  • ...
+5
source

Unfortunately, you cannot use different options for auto accessories in VB.NET. You must manually write the property code.

+1
source

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.

+1
source

All Articles