How do I write private set auto-properties in VB 10?

前端 未结 3 1698
轻奢々
轻奢々 2021-01-08 01:02

in C#:

public string Property { get; private set; }

in VB?

Please vote or/and share your ideas!

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-08 01:31

    According to this MSDN article, you can't:

    Auto-implemented properties are convenient and support many programming scenarios. However, there are situations in which you cannot use an auto-implemented property and must instead use standard, or expanded, property syntax.

    You have to use expanded property-definition syntax if you want to do any one of the following:

    [...]

    • Specify different accessibility for the Get and Set procedure. For example, you might want to make the Set procedure Private and the Get procedure Public.

提交回复
热议问题