View Single Post
  #4 (permalink)  
Old December 13th, 2005, 12:01 AM
nalla nalla is offline
Friend of Wrox
Points: 464, Level: 7
Points: 464, Level: 7 Points: 464, Level: 7 Points: 464, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: Colombo, , Sri Lanka.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default

Hi,

switch(value)
{
  case 0:
    printf(In case 0\n);
  case 1:
    printf(In case 1\n);
  case 2:
    printf(In case 2\n);
    break;
}

C/C++ allows us to use the switch statement like this without a break statement and this will result,

In case 0
In case 1
In case 2

But why can't use use the switch statement without a break or any jump statement in C# like we are using in C/C++?

I know we can implement fall-through in C# using "goto" in each case like, but C# still requires a jump statement.
switch(value)
{
  case 0:
    printf(In case 0\n);
    goto case 1;
  case 1:
    printf(In case 1\n);
    goto case 2;
  case 2:
    printf(In case 2\n);
    break;
}