Here's a list of features that I'd like to see in C#. I'm grouping them by version to show if/when they are ever handled.
2.0
With Statement
- Fall-Through
cases in switch Statement
- Optional Parameters
- Protected Interface Members
1.1
With Statement
- Fall-Through
cases in switch Statement
- Optional Parameters
- Protected Interface Members
1.0
With Statement
VB has a With statement that I find very useful. There are claims that a with block would be add to the complexity, but I don't agree. I do think it could be abused, but so could anything else. This is where our skills as developers need to overcome the fact that the language could be easier to use. Think about it this way, the alternative is to use short, nondescriptive variable names, which would be even worse.
- Fall-Through
cases in switch Statement
One of the major benefits of the switch statement in C++ was that you could perform some actions on one or two cases and "fall-through" another case to perform more actions. This is kind of hard to describe if you don't know what I mean, so here...
switch (someNumber)
{
case -1:
IsNegative = true;
break;
case 1:
IsPositive = true;
case 0:
IsNonNegative = true;
break;
}
- Optional Parameters
I have to say that I really do like VB's optional parameters. We can do this in C#, but it requires a lot more code. I think that compiling optional paramters into the overloaded counterparts would be very beneficial to developers, and wouls save a lot of time.
- Protected Interface Members
An interface is intended to tell other objects how to interact with the object. I have been in several situations where it'd be nice to specify a protected member that must be implemented because I want things to work a specific way. This would be helpful to instill certain practices. For instance, if I want to force an interface to have an Init event, I may also want to force a OnInit() method to raise that event.
See Also