I am trying to add a list to a for loop.
Here is my code
I created a property here
public class SampleItem
{
public int Id { get; set; }
public string StringValue { get; set; }
}
I want to add a value from another list
List<SampleItem> sampleItem = new List<SampleItem>();
for (int i = 0; i < otherListItem.Count; i++)
{
sampleItem[i].Id = otherListItem[i].Id;
sampleItem[i].StringValue = otherListItem[i].Name;
}
Can someone fix my code please.
source
share