How can I add sequence IDs to classes in a list of another class?
<p>I have the following class. Inside of the Parent class is a List of ParentDetail. Now I need to add a new field to the ParentDetail class. The field is called Id. What I need is a method in the main class that will iterate through the ParentDetails and populate the Id field with a number starting at 1. </p>

<p>Can anyone think of an easy way to do this? I am not sure how I can iterate through the List.</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; }  &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; new field
    }

}
</code></pre>
