What is the best way to get the list of column names using CsvHelper?
The previous answer used to work fine, but as of version 20 of csvhelper there is a breaking change. Now just access the header record from the reader directly:
csv.Read();
csv.ReadHeader();
string[] headerRow = csv.HeaderRecord;
The header record is on the csv context. It needs to be read beforehand before accessing.
csv.Read();
csv.ReadHeader();
string[] headerRow = csv.Context.HeaderRecord;