As a seasoned component developer I was a bit disappointed when I first made the move to .NET with respect to (really only) one thing: the ability to scope the property getters and setters individually. Back in the good ol' VB 6.0 and C++ days, it was common practice to create a property that was readonly externally and public internally to the application. This simplified semantics and the programming model was simpler. However, when I came into .NET I found abruptly that I would have to create a readonly property and then a separate accessor function to set the value of the property internally:
public int Age {
get { return _age; }
}
internal void setAge(int value) {
_age = value;
}
I am very excited to learn that in the Whidbey (Visual Studio 5.0) timeframe we'll get scoped property accessors. Now the syntax would be like the following:
public int Age {
get { return _age; }
internal set { _age = value; }
}
As Eric Porter reminds us, this is not just a C# feature, but you'll be able to do the same thing in VB.NET:
Public Property Age() As Integer
Get
Return _age
End Get
Friend Set(ByVal Value As Integer)
_age = Value
End Set
End Property
I can't wait for this enhancement!