Aquarium Blog

Tuesday, May 25, 2004

We got different accessibility for property getters and setters in C#!

This is an excerpt from page 89 of the updated "C# Version 2.0 Specification, May 2004" (Am I allowed to do this?):

25.1 Property accessor accessibility
Occasionally, a component design will indicate that a property should have different accessibility for the set accessor and the get accessor. Most commonly, one wishes to allow any code to call the get accessor, but restrict the set accessor to descendant types (protected access) or to types within the same program (internal access). With language extensions specified in this section, it becomes possible to express such designs in C#.

Many asked for this functionality to be part of C# and VB.NET. The usual answer was something like: "The C# Team sees no need for it. We think that two accessors with different accessibility should have different names. The VB.NET Team has decided to follow."

However, they were obviously listening. Maybe they realized that allowing different accessibility for getters and setters leads to less verbose interfaces. I guess it wasn't that hard to implement either.

.NET evolution is in the right hands! I wonder if we are getting this as soon on VB.NET.


Post a Comment

Links to this post:

Create a Link

<< Home