Michael Flanakin's Web Log

Comments and complaints on software and technology in general

  Home  |   Contact  |   Syndication    |   Login
  159 Posts | 18 Stories | 232 Comments | 497 Trackbacks

News

This weblog is no longer being maintained. For the latest, check out www.michaelflanakin.com!

Article Categories

Archives

Post Categories

Image Galleries

Miscellaneous

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

  1. With Statement
     
  2. Fall-Through cases in switch Statement
     
  3. Optional Parameters
     
  4. Protected Interface Members
     

1.1

  1. With Statement
     
  2. Fall-Through cases in switch Statement
     
  3. Optional Parameters
     
  4. Protected Interface Members
     

1.0

  1. 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.
     
  2. 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;
    }
  3. 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.
     
  4. 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

posted on Saturday, July 31, 2004 12:19 PM

Feedback

# re: C# Wish List 12/7/2004 1:09 PM JustMe
In surfing the WEB I found this, I got one solution for the
"switch" issue.

You can use multiple "case" to run the same statements:

switch (someNumber)
{
case -1:
IsNegative = true;
break;
case 1:
case 0:
IsNonNegative = true;
IsPositive = true;
break;
}


Noticed I do not have a "break" statement in "case 1:".
You MUST have a "break" statement if you have any other
statement in the "case". Otherwise you DON'T. This will
cause the "Fall-Through".

# re: C# Wish List 12/7/2004 1:16 PM Michael Flanakin
I already know that you can do that. As a matter of fact, that's the only way to specify some processing for more than one value. The problem lies in the fact that, using your scenario, 1 is positive and non-negative, while 0 is only non-negative. So, the code would need to (and can't) look like this:

switch (someNumber)
{
case -1:
IsNegative = true;
break;
case 1:
IsPositive = true;
case 0:
IsNonNegative = true;
break;
}


# re: C# Wish List 8/16/2005 2:00 PM Roberto
What about?

switch (someNumber)
{
case -1:
IsNegative = true;
break;
case 1:
IsPositive = true;
goto case 0;
case 0:
IsNonNegative = true;
break;
}


# re: C# Wish List 8/17/2005 5:59 AM Michael Flanakin
Haven't tried that. Not ideal, but if it'll work, then it's good enough. Thanks!


# re: C# Wish List 10/20/2009 4:01 PM Design my site
Thanks for very useful tips on C# Wish List.

# re: C# Wish List 1/26/2010 6:04 AM Boxfresh
Noticed I do not have a "break" statement in "case 1:".
You MUST have a "break" statement if you have any other
statement in the "case". Otherwise you DON'T. This will
cause the "Fall-Through".

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: