[Solved] C# CsvWriter throws “CsvWriter does not contain a constructor that takes 1 arguments” after update from 2.8.4 to 27.1.1


CultureInfo is needed to account for different formatting & parsings between various cultures as not everyone in the world formats dates, currency etc. the same.

If you don’t need to parse your data based on the user’s local settings, use CultureInfo.InvariantCulture:

using (var fs = new MemoryStream()) {
    using var tx = new StreamWriter(fs)
    using (var csv = new CsvWriter(tx, CultureInfo.InvariantCulture) {
        csv.WriteHeader<TemplateCsvModel>();
        csv.WriteRecords(templates);
        return Encoding.UTF8.GetPreamble().Concat(fs.ToArray()).ToArray();
      }
}

solved C# CsvWriter throws “CsvWriter does not contain a constructor that takes 1 arguments” after update from 2.8.4 to 27.1.1