VB.net automatic properties with different access level for set [duplicate]
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
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.
According to this answer, you can't.
精彩评论