FileHelpers - 'FieldConverter' 在此声明类型上无效

FileHelpers - 'FieldConverter' is not valid on this declaration type

我正在尝试设置通过 FieldConverter 属性读取的 CSV 文件的日期格式,但我收到以下错误 -

Attribute 'FieldConverter' is not valid on this declaration type. It is only valid on 'field' declarations.

知道为什么会这样吗?我该如何解决?

[DelimitedRecord(",")]
[IgnoreFirst(1)]
public class SomeViewModel
{   
    public int account { get; set; }

    [FieldConverter(ConverterKind.Date, "dd-MM-yyyy")]
    public DateTime doc_dte { get; set; }
}

正如您在错误消息中看到的,您不能在 属性 上使用属性 FieldConverter,只能在字段上使用。所以,只需将您的 属性 更改为一个字段:

[FieldConverter(ConverterKind.Date, "dd-MM-yyyy")]
public DateTime doc_dte;