2

In c# you can auto property a value with different level of access for the get and set . . . e.g.

public String myString
{
  get;
  private set;
}

Is there away to do that with automatic properties in vb.net or are you forced to go for the long winded implementation of properties?

e.g. I don't want to do this all the time

Dim _myString As String
Public Property MyString() As String
  Get
    Return _myString
  End Get
  Private Set(ByVal value As String)
    _myString = value
  End Set
End Property
Dustin Hodges
  • 4,110
  • 3
  • 26
  • 41

2 Answers2

2

It doesn't look like it's in VB.NET 2010 either. You can do this:

Public Property myProp As String = "Foo"

(This will give you a public getter and setter.)

But you can't set different levels of access. You would still have to manually implement them.

David Hoerster
  • 28,421
  • 8
  • 67
  • 102
0

According to this answer, you can't.

Community
  • 1
  • 1
Jon B
  • 51,025
  • 31
  • 133
  • 161