Property-scope variables - by drventure

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 676318 Comments
Status Closed Workarounds
Type Suggestion Repros 0
Opened 6/21/2011 12:03:33 PM
Access Restriction Public


One element that has always bugged me about .net langauges is the lack of a property scope variable.

For instance:

Property xyz
    Private PropVar as int
    Public Function Get()
        ' blah blah
    end Function
    Public Sub Set()
         ' blah blah
    end sub
End property

This would go a LONG way toward getting backing variables out of the regional scope in those cases (most of them) where they don't belong or have need to be in the regional scope.
Sign in to post a comment.
Posted by Microsoft on 5/14/2012 at 5:48 PM
Thanks for the suggestion. We discussed this at a language design meeting back in 2010. These were our notes...

PRO: This provides yet more encapsulation, and encapsulation is good.

CON: You usually want to set backing fields in constructors and deserializers. With this proposal you couldn't.

PRO: This design is compact: if you collapse the field, then the backing property is hidden, and it looks just like an auto-property.

CON: What about overriding? What is the accessibility of the field then?

CON: There are already too many levels of hiding variables from various bits of code (private, public, protected, friend, protected friend). Adding yet another way of hiding them is too much. If you can't trust "private" variables to be used properly within just one class, there are bigger problems at play.

I'll add your two votes to the feature on our internal list of possible future ideas, but I'm sorry to say that I don't think we'll do it. We'd only ever take on a new feature if it brought a significant advantage to count against its extra complexity, and this idea doesn't seem worth it.

Thanks again,

Lucian Wischik, VB language PM

Posted by Zaslow at Flexi on 1/26/2012 at 10:26 AM
I too would love to see this feature. By scoping the backing field(s) inside the property it would prevent someone from using the backing field(s) in unintended ways.
Posted by Microsoft on 6/21/2011 at 12:13 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(