title: List iteration using LINQ while showing the List position
body: <p>I just asked a question about my class:</p>
  
  <pre><code>Public class Parent {
          public IList&lt;ParentDetail&gt; ParentDetails {
              get { return _ParentDetails; }
          }
          private List&lt;ParentDetail&gt; _ParentDetails = new List&lt;ParentDetail&gt;();
          public Parent() {
              this._ParentDetails = new List&lt;ParentDetail&gt;();
          }
      }
  
      public class ParentDetail {
          public int Id { get; set; }
      }
  
  }
  </code></pre>
  
  <p>One of the experts here (Jon) told me how I could iterate through this class in order of the ParentDetails.Id.  Here's his solution which works good. 
  <a href="https://stackoverflow.com/questions/6413023/iterating-through-a-list-based-on-the-value-of-an-id-element-inside-the-list-in-c">Previous question</a></p>
  
  <pre><code>foreach(var details in Model.Parent.ParentDetails.OrderBy(d =&gt; d.Id))
  {
      // details are processed in increasing order of Id here
      // what's needed is to get access to the original order
      // information. Something like as follows:
      // select index position from ParentDetails where Id = details.ID
  }
  </code></pre>
  
  <p>What I also need is within this foreach to show the index value of the list corresponding to the Id along with some other data that's in the ParentDetail class. </p>
  
  <p>So for example where it says // details are processed then I want to be able to print out the index value that corresponded to the current Id in the foreach loop.</p>