'I using EnumerateRecords and GetRecords the same with CsvHelper
CsvHelper provides two methods to parse the file: EnumerateRecords and GetRecords
They provide examples for EnumerateRecords and GetRecords but they seem to do the same thing.
EnumerateRecords
using (var reader = new StreamReader("path\\to\\file.csv"))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
var record = new Foo();
var records = csv.EnumerateRecords(record);
foreach (var r in records)
{
// r is the same instance as record.
}
}
GetRecrods
using (var reader = new StreamReader("path\\to\\file.csv"))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
var records = csv.GetRecords<Foo>();
}
What is the use case for each method?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
