CsvDeserializationErrorContext Class

Describes an error of CsvSerializer while it converts records to objects, passed to CsvSerializerOptions.DeserializationErrorHandler.

public sealed class CsvDeserializationErrorContext

Properties

NameDescription
ColumnIndexGets the 0-based index of the column, or null when the error is not about one column.
ColumnNameGets the name of the column from the header row, or null when the data has no header row or the error is not about one column.
ExceptionGets the exception that the serializer throws for this error when the handler returns CsvDeserializationErrorAction.Throw, or when there is no handler.
KindGets the kind of error.
LineNumberGets the 1-based line number where the record starts.
MemberNameGets the column name of the member, as the type defines it, or null when the column has no member.
PositionGets the 0-based position, in characters or in bytes from the start of the data, where the record starts.
RawValueGets the value that cannot be converted, for CsvDeserializationErrorKind.ConversionFailed; otherwise, null.
RowIndexGets the 0-based index of the record, not counting the header row.
TypeGets the type of the objects being read.

Gets the 0-based index of the column, or null when the error is not about one column.

public int? ColumnIndex { get; }

Property value

int?

Gets the name of the column from the header row, or null when the data has no header row or the error is not about one column.

public string? ColumnName { get; }

Property value

string?

Gets the exception that the serializer throws for this error when the handler returns CsvDeserializationErrorAction.Throw, or when there is no handler.

public CsvException Exception { get; }

Property value

CsvException

Gets the kind of error.

public CsvDeserializationErrorKind Kind { get; }

Gets the 1-based line number where the record starts.

public long? LineNumber { get; }

Property value

long?

Gets the column name of the member, as the type defines it, or null when the column has no member.

public string? MemberName { get; }

Property value

string?

Remarks

When CsvSerializerOptions.PropertyNameCaseInsensitive is true, the header row can write it differently: CsvDeserializationErrorContext.ColumnName is the name as written in the header row.

Gets the 0-based position, in characters or in bytes from the start of the data, where the record starts.

public long? Position { get; }

Property value

long?

Gets the value that cannot be converted, for CsvDeserializationErrorKind.ConversionFailed; otherwise, null.

public string? RawValue { get; }

Property value

string?

Gets the 0-based index of the record, not counting the header row.

public long? RowIndex { get; }

Property value

long?

Remarks

The header row is checked when the first record is read: an error of the header row has the index of the first record.

Gets the type of the objects being read.

public Type Type { get; }

Property value

Type