title: Index was out of range. Must be non-negative and less than the size of the collection
body: <p>I'm trying to add a list in the for loop.</p>
  
  <p><strong>Here is my code</strong>
  I created a property here</p>
  
  <pre><code>    public class SampleItem
  {
      public int Id { get; set; }
      public string StringValue { get; set; }
  }
  </code></pre>
  
  <p>I want to add value from another list</p>
  
  <pre><code>List&lt;SampleItem&gt; sampleItem = new List&lt;SampleItem&gt;(); // Error: Index out of range
   for (int i = 0; i &lt; otherListItem.Count; i++)
   {
        sampleItem[i].Id = otherListItem[i].Id;
        sampleItem[i].StringValue = otherListItem[i].Name;
   }
  </code></pre>
  
  <p>Can someone correct my code please.</p>