I have same type of 2 object lists and first item of first list should be added specific times. Also every cycle i should increase the datetime value with AddSeconds()
. This is my code below:
List<Logs> logList = new List<Logs>();
List<Logs> chartList = new List<Logs>();
for (int i = 0; i < specificValue; i++)
{
chartList.Add(logList[0]);
logList[0].Date = logList[0].Date.AddSeconds(1);
}
My purpose is creating chart data with change log so i have to add same value to chartList with specific time with incremental date value. But my problem this code creates a chartList with all the same value of the last loglist item. I found some solutions with using foreach but in that situation i have to use for loop.