Die neueste CSVHelper -Konfiguration hat mehrere Mitglieder in Readonly geändert und Kompilierungsfehler auf vorhandenenC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Die neueste CSVHelper -Konfiguration hat mehrere Mitglieder in Readonly geändert und Kompilierungsfehler auf vorhandenen

Post by Anonymous »

Der folgende C# -Coder, der mit CSVReader funktioniert, wobei der Variablenleser ein StreamReader ist: < /p>
DataTable dataTable = null;
this._csvHeaders = null;
using (reader)
{
using (CsvReader csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
csv.Configuration.HasHeaderRecord = true;
csv.Configuration.MissingFieldFound = (field, index, context) => AddMissingFieldParseError(field, context.Row, index);
csv.Configuration.BadDataFound = (context) => AddBadDataFoundParseError(context.Field, context.Row);

using (CsvDataReader dataReader = new CsvDataReader(csv))
{
// Validate headers
this._csvHeaders = csv.Context.Reader.HeaderRecord.ToList();
TrimHeaderNames(ref _csvHeaders);
string errorMessage = string.Empty;
if (!ValidateHeaders(_csvHeaders, out errorMessage))
{
XOperationError operationError = new XOperationError("Duplicated error found", errorMessage);
this.ParseErrors.Clear();
this.ParseErrors.Add(0, new List { operationError });
return null;
}

dataTable = new DataTable();
dataTable.Load(dataReader);
}
}
}
< /code>
Jetzt funktioniert es nicht mehr wie HaSheadeerrecord, MissingFoundFound, Baddatafound wurde alle schreibgeschützt. CsvConfiguration config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
HasHeaderRecord = true,
MissingFieldFound = (field, index, context) => AddMissingFieldParseError(field, context.Row, index),
BadDataFound = (context) => AddBadDataFoundParseError(context.Field, context.Row)
};
< /code>
Jetzt beschwert es: < /p>

MissingFound enthält keine 3 Argumente < /li>
BadDatafoundArgs enthält keine Definition für Zeile < /li> < /> < /ol>
Ich bin wirklich verwirrt. Sind diese nur Syntaxfehler?
Eine Hilfe wird geschätzt.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post