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

Properties

IsEmpty

Added in v34.0.0
public bool IsEmpty { get; }

Whether the value is empty.

Property value

bool

View source

Length

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

The length of the value in bytes.

Property value

int

View source

Methods

Parse<T>()

Added in v34.0.0

net10.0

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

Parses the value as T. See CsvReader.Parse<T>(int).

Type parameters

T
The type to parse the value as.

Returns

T
The parsed value.

Exceptions

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

netstandard2.1, netstandard2.0, net47

public T Parse<T>()

Parses the value as T. See CsvReader.Parse<T>(int).

Type parameters

T
The type to parse the value as.

Returns

T
The parsed value.

Exceptions

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

View source

ParseOrNull<T>()

Added in v34.0.0

net10.0

public T? ParseOrNull<T>() where T : struct, ISpanParsable<T>

Parses the value as T, or returns null if it is empty, one of CsvReaderOptions.NullValues or invalid.

Type parameters

T
The type to parse the value as.

Returns

T?
The parsed value, or null when the value is null or not a valid T.

Exceptions

NotSupportedException
On .NET Framework and .NET Standard, T is not one of the built-in types.

netstandard2.1, netstandard2.0, net47

public T? ParseOrNull<T>() where T : struct

Parses the value as T, or returns null if it is empty, one of CsvReaderOptions.NullValues or invalid.

Type parameters

T
The type to parse the value as.

Returns

T?
The parsed value, or null when the value is null or not a valid T.

Exceptions

NotSupportedException
On .NET Framework and .NET Standard, T is not one of the built-in types.

View source

public T? ParseOrNull<T>(CsvTryParser<T> parser) where T : struct

Parses the value with parser, or returns null if it is empty, one of CsvReaderOptions.NullValues, or parser fails.

Type parameters

T
The type that parser parses.

Parameters

parserCsvTryParser<T> where T : struct
Tries to parse the value with the reader's format provider. It is not called for a null value.

Returns

T?
The parsed value, or null when the value is null or parser fails.

Exceptions

ArgumentNullException
The value is not null and parser is null.

View source

TryParse<T>(out T)

Added in v34.0.0

net10.0

public bool TryParse<T>(out T value) where T : ISpanParsable<T>

Tries to parse the value as T. See CsvReader.Parse<T>(int).

Type parameters

T
The type to parse the value as.

Parameters

valueT
The parsed value, or the default of T when parsing fails.

Returns

bool
Whether the value could be parsed.

Exceptions

NotSupportedException
On .NET Framework and .NET Standard, T is not one of the built-in types.

netstandard2.1, netstandard2.0, net47

public bool TryParse<T>(out T value)

Tries to parse the value as T. See CsvReader.Parse<T>(int).

Type parameters

T
The type to parse the value as.

Parameters

valueT
The parsed value, or the default of T when parsing fails.

Returns

bool
Whether the value could be parsed.

Exceptions

NotSupportedException
On .NET Framework and .NET Standard, T is not one of the built-in types.

View source

public bool TryParse<T>(CsvTryParser<T> parser, out T value)

Tries to parse the value with parser, which gets it as a string and the reader's format provider.

Type parameters

T
The type that parser parses.

Parameters

parserCsvTryParser<T>
Tries to parse the value with the given format provider.
valueT
The value that parser produced.

Returns

bool
The result of parser: whether the value could be parsed.

Exceptions

ArgumentNullException
parser is null.

View source