Request content you see to be in Visual Basic (provide a URL)

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

32 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  ·   ·  Admin →

    3 comments

    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...
      • AlexAlex commented  · 

        Auto-implemented readonly properties would be nice. I understand the difficulties in matching C#'s syntax for mixed access (and the fact it probably won't save much typing) but just being able to type:
        Public ReadOnly Property Whatever As Integer
        would be very useful.

      • SpottySpotty commented  · 

        The Feature of auto-implemented properties was done created for the majority case scenario which was read/write same access properties avoding to have to write boilerplate code. For any other scenarios read only/write only or different access the spec determined that these would probably be haved better by using full property syntax. If enough developers raised this as an issue then we could probably look at this again.

      • Jay XuJay Xu commented  · 

        In my opinion, we translated this to
        Private _MyProperty As Integer
        Public Property MyProperty As Integer
        Private Get
        Return _MyProperty
        End Get
        Set(ByVal value As Integer)
        _MyProperty = value
        End Set
        End Property
        or
        Private _MyProperty As Integer
        Public Property MyProperty As Integer
        Get
        Return _MyProperty
        End Get
        Protected Set(ByVal value As Integer)
        _MyProperty = value
        End Set
        End Property

        Because access modifier can only be applied to either 'Get' or 'Set', but not both.

      Feedback and Knowledge Base