I'm using CsvHelper (great package thanks Josh) and having problems with the constructor with .Net Core when using CultureInfo.
Josh's example has something like this... (from https://joshclose.github.io/CsvHelper/examples/writing/write-class-objects)
using (var writer = new StreamWriter("path\\to\\file.csv"))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteRecords(records);
}
However, that gives me, CS1503 Argument 2: cannot convert from 'System.Globalization.CultureInfo' to 'CsvHelper.Configuration.Configuration'
so, I need to do this instead
using (var writer = new StreamWriter("path\\to\\file.csv"))
using (var csv = new CsvWriter(writer: writer ))
{
csv.Configuration.CultureInfo = CultureInfo.InvariantCulture ;
csv.WriteRecords(records);
}
Is Josh's example wrong or am I doing something wrong ?
Josh's example works with the current CsvHelper, Version 13.0.0
using (var writer = new StreamWriter("path\\to\\file.csv"))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteRecords(records);
}
Before Version 13.0.0, your example works.
using (var writer = new StreamWriter("path\\to\\file.csv"))
using (var csv = new CsvWriter(writer))
{
csv.Configuration.CultureInfo = CultureInfo.InvariantCulture;
csv.WriteRecords(records);
}