【问题标题】:Reading "un-typed" CSV files in CsvHelper v7.1.1在 CsvHelper v7.1.1 中读取“未键入”的 CSV 文件
【发布时间】:2018-07-11 15:40:51
【问题描述】:

在 CsvHelper 2.16.3 中,我有以下代码

    public static IEnumerable<IEnumerable<string>> GetAllRecords(TextReader reader)
    {
        List<IEnumerable<string>> records = new List<IEnumerable<string>>();
        var csvConfiguration = new CsvConfiguration { HasHeaderRecord = false };

        using (var csv = new CsvReader(reader, csvConfiguration))
        {
            while (csv.Read())
            {
                records.Add(csv.CurrentRecord);
            }
        }

        return records;
    }

我正在升级一些软件包,我发现CsvReader.CurrentRecord 已被弃用并在某些时候被删除。从 7.1.1 版开始,最好的重写方法是什么?

【问题讨论】:

    标签: csvhelper


    【解决方案1】:

    很多东西都移到了上下文对象中。 csv.Context.Record

    【讨论】:

      猜你喜欢
      • 2021-10-02
      • 1970-01-01
      • 1970-01-01
      • 2021-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-12
      • 2014-09-20
      相关资源
      最近更新 更多