I suggest you ...

Mixed-access auto implemented properties like in C#

There should be a way to translate this to VB (one liner! }:)

public int MyProperty { private get; protected set; }

85 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
shimmy shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

Thanks for taking the time to share this suggestion. This item has been around for a couple of versions of Visual Studio and we haven’t acted on it. Looking at the VS “15” plans, we’re not going to take action on this item, so we’re going to close it. If the suggestion is still relevant, please either take a look to see if there’s another suggestion that’s similar that you can vote on, or open a new suggestion.

- The Visual Studio Team

4 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Anonymous commented  ·   ·  Flag as inappropriate

    What about allowing something like:
    Property Name as String
    Public Get
    Friend Set
    End Property

  • Anthony D. Green [MSFT] commented  ·   ·  Flag as inappropriate

    Hey shimmy,

    Sorry for the slow response but apparently this suggestion was made on a different UserVoice site than the VB team actually looks at and we only recently discovered it and moved it over to here.

    While we understand that this is convenient in C# we have to balance the convenience of having it in VB against the potentially lengthy or crypting syntax to fit it in. Off the top of my head the most VB syntax I come up with is something like:

    Public Property MyProperty As Integer With Protected Set

    Which looks a little ... inelegant. We are planning to add ReadOnly auto-properties in the next release like this:

    ReadOnly Property MyProperty As Integer

    You could set these in the constructor. We think of this as solving the most common usages of { get; private set;} auto-props in C#.

    Could you tell us more about the scenarios where you'd use this feature often?

    -Anthony D. Green, Program Manager, Visual Basic & C# Languages Team

Feedback and Knowledge Base