Quote:
Originally Posted by jee7s
Yes, that's a switch-case statement. However, a fall-through switch case statement is a little different:
I might be wrong about that VB switch statement, but I'm pretty sure it doesn't support the fall-through idea.
de KG2OV
|
Thanks for the clarification. I should have know that, but I don't remember ever seeing that in practice.
However, after reading your post i decided to try that in C#, and as far as I can tell C# dosn't support that either.
This code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i = 10;
switch (i) {
case (1):
Debug.Print("1");
case (2):
Debug.Print("2");
}
}
}
}
generates these errors:
Error 1 Control cannot fall through from one case label ('case 1:') to another C:\Users\Eric Haskins\Documents\Visual Studio 2008\Projects\ConsoleApplication1\ConsoleApplicati on1\Program.cs 15 17 ConsoleApplication1
Error 2 Control cannot fall through from one case label ('case 2:') to another C:\Users\Eric Haskins\Documents\Visual Studio 2008\Projects\ConsoleApplication1\ConsoleApplicati on1\Program.cs 17 17 ConsoleApplication1
Am I being stupid again, or is this a limitation of all .net languages?
EDIT: I found my own answer.
http://msdn2.microsoft.com/en-us/lib...28(VS.90).aspx That seems slightly old VBish.
EDIT: More info
http://blogs.msdn.com/abhinaba/archi...15/492866.aspx
-Eric