switch(time)
{

case 1: System.Console.WriteLine(" Enter the century. ie 20 or 19.");
C = System.Console.ReadLine();
Convert.ToInt32(C);
goto case 2;


case 2: System.Console.WriteLine("Enter year in YY format. ie 96") ;
Y = System.Console.ReadLine();
Convert.ToInt32(Y);
goto case 3;


case 3: System.Console.WriteLine("Enter month in MM format. ie 03");
M = System.Console.ReadLine();
Convert.ToInt32(M);
goto case 4;
case 4: System.Console.WriteLine("Enter the two digit day of the month. ie 13");
D = System.Console.ReadLine();
Convert.ToInt32(D);
break;
}

I want this switch statemement to fall through. Whats preventing it??

* It wasnt the switch statement at all* oops

Yeah, C# doesn't support falling through on switch statements ;)

That's one of the fallbacks of a "strong" language such as C# over a "weak" one such as C (this is not a comparing of the strength of the language but the strength of the safeguards build into the language). You might just have to use nested if blocks to accomplish your goal whereas this could easily be done in C.

Regards,

Tyler S. Breton

By the way,

C# does not allow this the way you wish to have it done, executing multiple lines of code in one case and jumping to another (unless you use proper goto statements *bad practice*, which ARE supported in C#). However, you CAN fall through one case to another if and only if the case is blank, which technically isn't "falling through" the way we think of it, but in reality just declaring more than once case for a particular chunk of code.

Example:

switch(a)
{
 
    case 1:
    case 2:
    case 3:
        x++;
        break;
    case 4:
        y++;
        break;
 
    default:
        z++;
        break;
 
}

Hope this clarifies things a bit.

Best Regards,

Tyler S. Breton

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.