CsvRow Class

Represents a row in a CSV file with access to values by column index or name.

Example

using var reader = new StringReader("Name,Age\nJohn,30");
var csvReader = new CsvReader(reader) { HasHeaderRow = true };
var row = await csvReader.ReadRowAsync();

// Access by column name
Assert.Equal("John", row!["Name"]);

// Access by column index
Assert.Equal("30", row[1]);
Implements

Constructors

NameDescription
CsvRow(IReadOnlyList<CsvColumn>?, IReadOnlyList<string>)Initializes a new instance of the CsvRow class.

CsvRow(IReadOnlyList<CsvColumn>?, IReadOnlyList<string>)

CsvRow.cs

Initializes a new instance of the CsvRow class.

protected internal CsvRow(IReadOnlyList<CsvColumn>? columns, IReadOnlyList<string> values)

Parameters

columns IReadOnlyList<CsvColumn>?
The columns of the row, or null if the CSV file has no header row.
values IReadOnlyList<string>
The values of the row.

Properties

NameDescription
ColumnsGets the columns of the row, or null if the CSV file has no header row.
System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<System.String,System.String>>.Count
System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>.Keys
System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>.Values
ValuesGets the values of the row.

Columns

CsvRow.cs

Gets the columns of the row, or null if the CSV file has no header row.

public IReadOnlyList<CsvColumn>? Columns { get; }

System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<System.String,System.String>>.Count

CsvRow.cs

Property value

int

No documentation is available.

System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>.Keys

CsvRow.cs

Property value

IEnumerable<string>

No documentation is available.

System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>.Values

CsvRow.cs

Property value

IEnumerable<string>

No documentation is available.

Values

CsvRow.cs

Gets the values of the row.

public IReadOnlyList<string> Values { get; }

Property value

IReadOnlyList<string>

Indexers

NameDescription
this[CsvColumn]Gets the value of the specified column, or null if the row has no value at the column's index.
this[int]Gets the value at the specified column index.
this[string]Gets the value of the column with the specified name.
this[string]

Item overloads

this[CsvColumn]

CsvRow.cs

Gets the value of the specified column, or null if the row has no value at the column's index.

public virtual string? this[CsvColumn column] { get; }
Parameters
column CsvColumn
The column.
Property value

string?

Exceptions
ArgumentNullException
column is null.

this[int]

CsvRow.cs

Gets the value at the specified column index.

public virtual string? this[int index] { get; }
Parameters
index int
The zero-based index of the column.
Property value

string?

Exceptions
ArgumentOutOfRangeException
index is less than 0 or greater than or equal to the number of values.

this[string]

CsvRow.cs

Gets the value of the column with the specified name.

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

string?

Exceptions
ArgumentNullException
columnName is null.
InvalidOperationException
The CSV file has no header row.

this[string]

CsvRow.cs

Parameters

key string

Property value

string?

No documentation is available.

Methods

NameDescription
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,System.String>>.GetEnumerator()
System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>.ContainsKey(string)
System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>.TryGetValue(string, string?)
System.Collections.IEnumerable.GetEnumerator()

System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,System.String>>.GetEnumerator()

CsvRow.cs

System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>.ContainsKey(string)

CsvRow.cs

Parameters

key string

Returns

bool

No documentation is available.

System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>.TryGetValue(string, string?)

CsvRow.cs
bool IReadOnlyDictionary<string, string>.TryGetValue(string key, out string? value)

Parameters

key string
value string?

Returns

bool

No documentation is available.

System.Collections.IEnumerable.GetEnumerator()

CsvRow.cs
IEnumerator IEnumerable.GetEnumerator()

No documentation is available.