title: Finding the highest set flag in an enum value
body: <p>I'm using a enum with flags attribute as a way of tracking status.</p>
  
  <p>An example is the following:</p>
  
  <pre><code>Created = 1
  Completed = 2
  Dispatched = 4
  </code></pre>
  
  <p>Without writing anything too rigid (if check this, do that, if check that, do this) i want to be able to find the highest flag which has been set so in this example:</p>
  
  <pre><code>Item.Status = Status.Created | Status.Completed
  </code></pre>
  
  <p>the mythical method would return 2 - as completed is the flag set with the highest value.</p>
  
  <pre><code>GetMaxSetFlagValue(Item.Status) // returns 2
  </code></pre>
  
  <p>I've found questions which revolved around the actual enum, just not a value which uses flags.  I'm fairly sure this could be achieved with Linq...?</p>