开发者

VB.net automatic properties with different access level for set [duplicate]

This question already has answers here: How do I write private set auto-properties in VB 10? 开发者_JAVA百科 (3 answers) Closed 8 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜