Get Record Row Index

May 17, 2010 at 1:43 PM

Hello,

Is there a built in property, method or anything that returns the index (row number) of the current record?

For example in:

        using (var reader = new CsvReader(stream)) {
          reader.ReadHeaderRecord();

          foreach (var record in reader.DataRecords) {

            Task task = new Task {
              Client = record["Nome Cliente"],
              Comment = record["Commentarios"],
            };

            Int32 i = record ??? Get row number of record in CSV file

Thank You,

Miguel

Coordinator
May 21, 2010 at 11:16 PM
Hi Miguel, The CsvReader class has a RecordNumber property that you can use. Please refer to the docs for specifics on how it works. Best, Kent