Namespace
CsvHelper
Assembly
CsvHelper.dll
Inheritance
object Attribute CsvFormatAttribute
Builds
net10.0 netstandard2.1 netstandard2.0 net47

Remarks

DateTime and DateTimeOffset members are read with CsvReader.ParseExact<T>(int, string, IFormatProvider); members of other types, such as DateOnly, TimeOnly and TimeSpan, with their static ParseExact(string, string, IFormatProvider) method.

With several formats, a field may have any of them, tried in order (ParseExact with a format array), and the record writer writes the first.

Constructors

public CsvFormatAttribute(string format, params string[] alternateFormats)

Reads the member with whichever of the formats the field has, tried in order, for files that mix them, such as [CsvFormat("yyyy-MM-dd", "dd/MM/yyyy")]. The record writer writes format.

Parameters

formatstring
The first format, which the record writer writes.
alternateFormatsstring[]
The other formats the field may have.

View source

Properties

Format

Added in v34.0.0
public string Format { get; }

The exact format of the field, or the first of Formats.

Property value

string

View source