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 CsvRecordProperties
| Name | Description |
|---|---|
| ColumnCount | Gets the number of columns of the record. An empty line has no column. |
| LineNumber | Gets the 1-based line number where the record starts. |
| RawSpan | Gets the text of the record, as it is in the data, without its line terminator. |
| RowIndex | Gets the 0-based index of the record. The header row and the comment lines are not counted. |
ColumnCount
CsvRecord.csLineNumber
CsvRecord.csRawSpan
CsvRecord.csGets the text of the record, as it is in the data, without its line terminator.
public ReadOnlySpan<char> RawSpan { get; }Property value
RowIndex
CsvRecord.csIndexers
| Name | Description |
|---|---|
| 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.csGets the value of a column.
Parameters
indexIndex- The index of the column, which can be from the end, such as
^1for the last column.
Property value
Exceptions
ArgumentOutOfRangeException- The record has no column at
index.
this[int]
CsvRecord.csGets the value of a column.
Parameters
indexint- The 0-based index of the column.
Property value
Exceptions
ArgumentOutOfRangeException- The record has no column at
index.
this[string]
CsvRecord.csGets the value of the column with the specified name in the header row.
Parameters
columnNamestring- The name of the column.
Property value
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
| Name | Description |
|---|---|
| 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.csToStringArray()
CsvRecord.csGets the values of all the columns as strings.
public string[] ToStringArray()Returns
string[] The values of the record.
TryGetField(string, CsvField)
CsvRecord.csGets the value of the column with the specified name in the header row.
Parameters
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.