title: Index or Position of a string within an list of ienumerable strings
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1290603/how-to-get-the-index-of-an-element-in-an-ienumerable">How to get the index of an element in an IEnumerable?</a>  </p>
  </blockquote>
  
  
  
  <p>i have this following function that accepts ienumerable string list.</p>
  
  <p>I loop through all the strings and if its value equals "<code>TestName</code>" (case insensitive), i return its position.</p>
  
  <pre><code>    int GetMyTestColumnPosition(IEnumerable&lt;string&gt; TitleNames)
      {
          foreach (var test in TitleNames)
          {
              if (string.Compare(test, "testname", stringComparison.CurrentCultureIgnoreCase) == 0)
              {
                  // return TitleNames.IndexOf(test); does not work!
              }
          }
      } 
  </code></pre>
  
  <p>EDIT: I changed the parameter to "<code>IList&lt;string&gt;</code>" and this works! But,</p>
  
  <ol>
  <li>How to find index or position of a string within an ienumerable string list ?</li>
  <li>Why does the ienumerable does not support index ? (we are not changing any value with in the list, we are just finding out its position!)</li>
  </ol>