I was reading an interesting article here and it made an interesting point about the 'case' statement in vb.net vs the 'switch' statement in C#, which I've pasted below:
The following Visual Basic Select Case statement can't be represented in C# with a single switch statement:
Dim Condition As Integer = 55
Select Case Condition
Case 1, 3 To 5, 10, 12, 14, Is > 50
'value 55 executes code here
Case Else
'values <1, 2, 6-9, 11, 13, 15-49
End Select
I've always found the switch statement in C#, with dropthrough and consequentrequirements for a break in each case, to be a bit unwieldy. Is there any reason they haven't enhanced the switch command to allow these situations? When would dropthrough be useful anyway? Anyone know of any extensions of the construct to allow more flexibility?
Cheers