Case specifies a constant to be matched in the switch selection statement. Listing 3 uses an enum in a case statement and checks if the DayOfWeek is Saturday or Sunday; it's a weekend or a work day. Saturday: case. The if, if-else, and switch statements select statements to execute from many possible paths based on the value of an expression. The if-else statement lets you choose which of the two code paths to. How can a switch expression be written to support multiple cases returning the same result? With C# prior to version 8, a switch may be written like so: var resultText = string. Empty; switch (switchValue) case 1: case 2: case 3: resultText = "one to three"; break; case 4: resultText = "four";. It depends on the requirement. if you need flexibility with different types of interfaces and speeds (copper, fiber, POE, etc) and also Sup redundancy inside the switch then a chassis works usually better than a fixed switch. WriteLine("Type in a super hero's name to see his nickname:"); string userValue = Console.
[PDF Version]