CsvFormatAttribute(string)
public CsvFormatAttribute(string format)Reads the member with the given format.
Parameters
formatstring- The exact format of the field, as DateTime.ParseExact(string, string, IFormatProvider) takes it.
Attribute in CsvHelper
Reads a member of a CsvRecordAttribute type with an exact format, such as "yyyyMMdd", instead of the formats that the format provider accepts.
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
public sealed class CsvFormatAttribute : AttributeCsvHelperCsvHelper.dllDateTime 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.
public CsvFormatAttribute(string format)Reads the member with the given format.
formatstringpublic 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.
formatstringalternateFormatsstring[]public string Format { get; }The exact format of the field, or the first of Formats.
public IReadOnlyList<string> Formats { get; }Every format the field may have, in the order they are tried.