title: C# - Prettier way to compare one value against multiple values in a single line of code
body: <p>I have this piece of code:</p>
  
  <pre><code>if (filter != RECENT &amp;&amp;
      filter != TODAY &amp;&amp;
      filter != WEEK &amp;&amp;
      filter != MONTH &amp;&amp;
      filter != ALLTIME)
  {
      filter = RECENT;
  }
  </code></pre>
  
  <p>Note that <code>filter</code> is a <code>string</code> and it's compared against <code>const string</code> types. Is there any way to do this inline and have it be more readable? Doing it with the ternary operator doesn't make it much better since I still have to repeat <code>filter != XXXXX</code></p>
  
  <pre><code>filter = filter != RECENT &amp;&amp;
           filter != TODAY &amp;&amp;
           filter != WEEK &amp;&amp;
           filter != MONTH &amp;&amp;
           filter != ALLTIME ? RECENT : filter;
  </code></pre>
  
  <p>and this clearly doesn't work</p>
  
  <pre><code>filter = filter != RECENT &amp;&amp; TODAY &amp;&amp; WEEK &amp;&amp; MONTH &amp;&amp; ALLTIME ? RECENT : filter;
  </code></pre>
  
  <p>Is there any prettier way (prettier == all of the logic must be in a single line of code) to do this comparison? More specifically to prevent <code>filter != XXXXX</code> repetition.</p>
  
  <p><em>Note that performance is not my primary concern for this question.</em></p>