What is the consequence of having two identical case labels in a switch statement?

  • It will automatically remove the duplicate label
  • It will lead to unpredictable behavior
  • It will result in a compilation error
  • It will work as expected, executing the code block for that case
Having two identical case labels in a switch statement is not allowed in C# and will result in a compilation error. Each case label should be unique within the switch statement to avoid ambiguity.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *