CsvRecord Struct

  • Obsolete: Types with embedded references are not supported in this version of your compiler.

A record read by CsvReader. It is valid until the next record is read.

[Obsolete("Types with embedded references are not supported in this version of your compiler.", true)]
public readonly ref struct CsvRecord

Properties

NameDescription
ColumnCountGets the number of columns of the record. An empty line has no column.
LineNumberGets the 1-based line number where the record starts.
RawSpanGets the text of the record, as it is in the data, without its line terminator.
RowIndexGets the 0-based index of the record. The header row and the comment lines are not counted.

ColumnCount

CsvRecord.cs

Gets the number of columns of the record. An empty line has no column.

public int ColumnCount { get; }

Property value

int

LineNumber

CsvRecord.cs

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

public long LineNumber { get; }

Property value

long

Gets the text of the record, as it is in the data, without its line terminator.

public ReadOnlySpan<char> RawSpan { get; }

Property value

ReadOnlySpan<char>

RowIndex

CsvRecord.cs

Gets the 0-based index of the record. The header row and the comment lines are not counted.

public long RowIndex { get; }

Property value

long

Indexers

NameDescription
this[Index]Gets the value of a column.
this[int]Gets the value of a column.
this[string]Gets the value of the column with the specified name in the header row.

Item overloads

this[Index]

CsvRecord.cs

Gets the value of a column.

public CsvField this[Index index] { get; }
Parameters
index Index
The index of the column, which can be from the end, such as ^1 for the last column.
Property value

CsvField

Exceptions
ArgumentOutOfRangeException
The record has no column at index.

this[int]

CsvRecord.cs

Gets the value of a column.

public CsvField this[int index] { get; }
Parameters
index int
The 0-based index of the column.
Property value

CsvField

Exceptions
ArgumentOutOfRangeException
The record has no column at index.

this[string]

CsvRecord.cs

Gets the value of the column with the specified name in the header row.

public CsvField this[string columnName] { get; }
Parameters
columnName string
The name of the column.
Property value

CsvField

Exceptions
InvalidOperationException
The reader has no header row.
KeyNotFoundException
The header row has no column with this name.
ArgumentOutOfRangeException
The record is shorter than the header row and has no value for this column.

Methods

NameDescription
ToString()Gets the text of the record, as it is in the data.
ToStringArray()Gets the values of all the columns as strings.
TryGetField(string, CsvField)Gets the value of the column with the specified name in the header row.

ToString()

CsvRecord.cs

Gets the text of the record, as it is in the data.

public override string ToString()

Returns

string The text of the record.

ToStringArray()

CsvRecord.cs

Gets the values of all the columns as strings.

public string[] ToStringArray()

Returns

string[] The values of the record.

TryGetField(string, CsvField)

CsvRecord.cs

Gets the value of the column with the specified name in the header row.

public bool TryGetField(string columnName, out CsvField field)

Parameters

columnName string
The name of the column.
field CsvField
The value of the column.

Returns

bool true when the header row has a column with this name and the record has a value for it; otherwise, false.

Exceptions

InvalidOperationException
The reader has no header row.