this post was submitted on 04 Jul 2023
9 points (84.6% liked)

.NET

1428 readers
21 users here now

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

Wikipedia pages

founded 1 year ago
MODERATORS
 

What does "control falls through a switch statement" mean in this context? Control just moves on to the next statement?

I thought if there is no match and a default case doesn't exist it will raise an exception. Is it not true?

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 3 points 1 year ago (1 children)

I think even switch statement doesn't allow it [...]

A switch statement allows fall through when the case itself doesn't have an implementation.

For example this is also considered a fall through:

        switch (x)
        {
            case "One":
            case "Two":
                Console.WriteLine("One or two");
                break;
        }
[โ€“] [email protected] 1 points 1 year ago

TIL!!!

Thank you!