title: In C#, How To Perform Pattern Matching With Switch For Non-Constant String Value?
body: <p><strong>In C#, How To Perform Pattern Matching With Switch For Non-Constant String Value?</strong></p>
  <p>I'd like to be able to use non-constant string variables as the match target in a switch statement.</p>
  <p>I have the code below, but I'm encountering error <code>CS0150: A constant value is expected</code> at <code>case expectedValue:</code></p>
  <pre class="lang-cs prettyprint-override"><code>public bool UseStandardSwitch(string inputValue)
  {
      var expectedValue = &quot;SomeValue&quot;;
  
      bool result = default;
      var DoSomething = () =&gt; { result = true; };
              
      switch (inputValue)
      {
          case expectedValue:
              DoSomething();
              break;
          default:
              break;
      }
      return result;
  }
  </code></pre>
  <p>Is there a way to achieve a similar result?</p>