Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Apr 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    G'Day all,
    I'm having trouble with the switch...case statement in C#. I get a variable that has the number of days until an expiry date. I then need to do something depending on how many days left until expiry but for some reason, C# won't let me do this:

    Code:
    switch (daysUntilExpiry) {
       case > 60:
         do something;
         break;
       case < 61:
         do somethingSomething;
         break;
       default:
         do somethingSomethingDarkSide;
         break;
    }
    I've googled, and helped and MSDN'd to no avail. Any ideas?

    Cheers
    toncc

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are using IF statement syntax for a SWITCH. Case values in a switch (other than default) have to be precise values - such as case 60:
    Gre

  3. #3
    Lounger
    Join Date
    Apr 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Gahh! One area where VB has an edge over C#... I hate using lots of IF statements to evaluate stuff like this.

    Oh well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •