About 50 results
Open links in new tab
  1. c# - Multiple cases in switch statement - Stack Overflow

    In C# 7 (available by default in Visual Studio 2017/.NET Framework 4.6.2), range-based switching is now possible with the switch statement and would help with the OP's problem.

  2. c# - How add "or" in switch statements? - Stack Overflow

    Apr 18, 2015 · 6 The example for switch statement shows that you can't stack non-empty case s, but should use goto s:

  3. Inline switch / case statement in C# - Stack Overflow

    Inline switch / case statement in C# Asked 15 years, 4 months ago Modified 2 years, 10 months ago Viewed 99k times

  4. Add a additional condition to Case Statement in Switch

    Jan 10, 2013 · 1 You can't add condition to a case. Case clause has to be a compile time constant. Instead you can use an if statement inside the case statement.

  5. Combine return and switch in C# - Stack Overflow

    This Stack Overflow page discusses combining return and switch statements in C# programming, offering insights and examples for developers.

  6. c# - Switch case: can I use a range instead of a one number - Stack ...

    In C# switch cases are basically dictionaries on what to do next. Since you can't look up a range in a dictionary, the best you can do is the case ... when statement Steve Gomez mentioned.

  7. How to make C# switch statement use IgnoreCase?

    Please have a look: Pattern Matching in C# 7.0 Case Blocks EDIT In light of @LewisM's answer, it's important to point out that the switch statement has some new, interesting behavior. That is that if …

  8. How can I use the string value of a C# enum value in a case statement ...

    I have defined a C# enum as public enum ORDER { ... unknown, partial01, partial12, partial23, } and can use its value as a string as in: string ss = ORDER.partial01.

  9. Switch case in C# - a constant value is expected

    For Case statements you can use expressions (function calls, variables, etc) whereas C# needs constant values (no function calls, variables, etc). The switch statement is quite limited comparably.

  10. C# Switch-case string starting with - Stack Overflow

    Oct 4, 2010 · The switch statement takes an expression that is only evaluated once. Based on the result, another piece of code is executed. So what? => String.StartsWith is a function. Together with a given …