You may maintain a Dictionary<TKey, TValue>
where TKey
would be the type of the values stored in ID
column and TValue
would be the type of a particular record (You may define a class that would contain the fields, one for each column in the csv).
Then just assign the new record to the dictionary against the ID
key to which it belongs.
In this way, you can ensure that all the keys have updated records (also DateTime inside of these) in the dictionary. It is also time-efficient, indeed.
Here is an example code:
public class Record // this class represents a particular record in the csv
{
public int ID { get; set; }
public DateTime DateTime { get; set; }
// other columns like above
}
then in the client code:
Dictionary<int, Record> dictionaryIdRecord = new Dictionary<int, Record>();
// `records` is the List of <Record>s in the csv
foreach (Record record in records)
{
dictionaryIdRecord[record.ID] = record;
}