title: Getting an array's index from custom valued indexed array
body: <pre><code>SortedList&lt;string, int&gt; list = new SortedList&lt;string, int&gt;;
  list.Add("abc", 2);
  list.Add("def", 3);
  
  string index = list.GetIndex(2) ???????
  Console.WriteLine(index);
  </code></pre>
  
  <p>I'm really confused. How can I get an array's index by using the index's value??</p>
  
  <p>Output should be</p>
  
  <blockquote>
    <p>abc</p>
  </blockquote>
  
  <p>Solutions:</p>
  
  <p>Use the IndexOfValue method that SortedList exposed, with combination of the Linq extension method ElementAt(int index), so:</p>
  
  <pre><code>string index = list.ElementAt(list.IndexOfValue(value)).Key;//output will be abc
  </code></pre>
  
  <p>---o---</p>
  
  <p>This also works</p>
  
  <pre><code>string index = list.Keys.ElementAt&lt;string&gt;(list.IndexOfValue(2));
  </code></pre>