public readonly ref struct CsvRow
Namespace
CsvHelper
Assembly
CsvHelper.dll
Builds
net10.0 netstandard2.1 netstandard2.0 net47
Source
CsvRow.cs

Properties

FieldCount

Added in v34.0.0
public int FieldCount { get; }

The number of fields in the record.

Property value

int

View source

RowNumber

Added in v34.0.0
public long RowNumber { get; }

The 1-based number of the data record.

Property value

long

View source

Indexers

Methods

GetSpan(int)

Added in v34.0.0
public ReadOnlySpan<byte> GetSpan(int index)

Gets the value of field index as UTF-8 bytes. See CsvReader.GetSpan(int).

Parameters

indexint
The 0-based index of the field.

Returns

ReadOnlySpan<byte>
The value of the field as UTF-8 bytes; empty for an empty field. Valid until the next read.

Exceptions

ArgumentOutOfRangeException
index is negative.

View source

Parse<T>(int)

Added in v34.0.0

net10.0

public T Parse<T>(int index) where T : ISpanParsable<T>

Parses field index as T. See CsvReader.Parse<T>(int).

Type parameters

T
The type to parse the field as.

Parameters

indexint
The 0-based index of the field.

Returns

T
The parsed value.

Exceptions

FormatException
The field is not a valid T.
OverflowException
The field is outside the range of T.
NotSupportedException
On .NET Framework and .NET Standard, T is not one of the built-in types.
ArgumentOutOfRangeException
index is negative.

netstandard2.1, netstandard2.0, net47

public T Parse<T>(int index)

Parses field index as T. See CsvReader.Parse<T>(int).

Type parameters

T
The type to parse the field as.

Parameters

indexint
The 0-based index of the field.

Returns

T
The parsed value.

Exceptions

FormatException
The field is not a valid T.
OverflowException
The field is outside the range of T.
NotSupportedException
On .NET Framework and .NET Standard, T is not one of the built-in types.
ArgumentOutOfRangeException
index is negative.

View source

public T Parse<T>(int index, Func<string, IFormatProvider, T> parser)

Parses field index with parser (see CsvReader.Parse<T>(int, Func<string, IFormatProvider, T>)).

Type parameters

T
The type that parser returns.

Parameters

indexint
The 0-based index of the field.
parserFunc<string, IFormatProvider, T>
Parses the value of the field with the reader's format provider.

Returns

T
The value that parser returns.

Exceptions

ArgumentNullException
parser is null.
ArgumentOutOfRangeException
index is negative.

View source

ToArray()

Added in v34.0.0
public string[] ToArray()

Copies all fields of the record into a new string array.

Returns

string[]
The values of the fields, one element per field.

View source

ToDictionary()

Added in v34.0.0
public Dictionary<string, string?> ToDictionary()

Copies the record into a new dictionary keyed by column name: the header names (each once, with its first column), or Field1, Field2 and so on without a header. A value is null when it is one of CsvReaderOptions.NullValues, as for CsvReader.GetStringOrNull(int).

Returns

Dictionary<string, string?>
The values of the record by name, in column order.

Exceptions

View source

ToString()

Added in v34.0.0
public override string ToString()

Gets the record as it appears in the input, without the line break.

Returns

string
The raw record decoded from UTF-8, quotes and escapes included.

View source