Auto Property with public getter and private setter

In VB.NET it's

Public ReadOnly Property Value As String

Then to access the private setter, you use an underscore before your property name

Me._Value = "Fred"

Using VB.NET, if you want to specify different accessibility for the Get and Set procedure, then you cannot use an auto-implemented property and must instead use standard, or expanded, property syntax.

Read MSDN: https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/auto-implemented-properties


If getter and setter have same accessibility, e.g. both are Public, then you can use the auto-property syntax, e.g.:

Public Property Prop2 As String = "Empty"

Tags:

Vb.Net