Switch order when two cases meet condition, How precedence work here?
IF name = "John Dee"
which one case hit first ?
2 Replies
Starts checking the cases from up to bottom. Whenever case matches, it goes inside the case, if you used break; then it wont go further down to check other cases
If you don't use break; then it will still check for other cases
You can easily debug the behavior
In you example first case will be hit and DoSomething1 is executed then switch statement breaked, meaning no more case check further below
C# doesn't let you fallthrough to the next case by leaving out the break
But yes, it checks in order from top to bottom