title: C# get enumeration index
body: <p>I have this enumeration:</p>
  
  <pre><code>public enum SymbolPair
      { 
          AUDJPY = 0, AUDNZD, AUDUSD, CADJPY, CHFJPY, EURCHF, EURGBP, EURJPY, EURUSD, GBPJPY, GBPUSD, NZDUSD, USDCAD, USDCHF, USDJPY 
      }
  </code></pre>
  
  <p>And I have a collection of symbol strings </p>
  
  <pre><code>List&lt;string&gt; symbols = new List&lt;string&gt;(){ };
  </code></pre>
  
  <p>Symbols are loaded into the collection dynamically depending on which symbols are entered in the input parameters. They can be loaded in any order and any count.</p>
  
  <p>So for example one set can load in "EUR/USD", "CHFJPY", "GBPUSD" </p>
  
  <p>I need to find the indexes corresponding to the index of the enumeration type. For example in this case I need the indexes 8, 4, and 10.</p>
  
  <p>Can someone please give an idea how to do this with linq or delegates or any other efficient way.
  Thanks</p>
  
  <p>EDIT: I need something along these lines but this doesn't work since linq does return a single value. How can I get that single index?</p>
  
  <pre><code>    SymbolPair[] enumList = (SymbolPair[])Enum.GetValues(typeof(SymbolPair));
  
      foreach (string symbol in symbols)
      {           
          int instrumentIndex = from symbolPair in enumList 
                                 where symbolPair.ToString() == symbol
                                  select (int)symbolPair;
      }
  </code></pre>