Does VB.NET support automatic property getters and setters?

In C #, I can do this:

public string myProperty { get; private set; } 

This is called an β€œauto receiver / setter” (from what I heard). Does VB.NET support these? So far, with my properties, all I can do is:

 Public Property myProperty As String Get Return String.Empty End Get Private Set(ByVal value As String) somethingElse = value End Set End Property 

which is extremely awkward.

So ... is there a better way?

+6
source share
2 answers

Yes.

 Public Property MyProperty As String 

However, you can only make it ReadOnly in VB 14 (vs 2015) or newer.

+19
source

Source: https://habr.com/ru/post/885423/


All Articles