views:

30

answers:

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
A: 

According to this answer, you can't.

Jon B
+1  A: 

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