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; }

36 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    shimmyshimmy shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Anthony D. Green [MSFT]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