如何使用FileHelper FieldOptional

时间:2017-04-30 16:02:03

标签: c# filehelpers

我已经添加了FieldOptional属性,但仍然会收到此错误

行:1栏:117。分隔符&#39;,&#39;在字段&#39; <TrackDate>k__BackingField&#39;之后找不到(记录的字段较少,分隔符错误或下一个字段必须标记为可选字段。&#34;

我的田野课程:

[DelimitedRecord(",")]

public class MaltaIn
{
    [FieldOrder(0)]
    public string MilesEventCode { get; set; }
    [FieldOrder(1)]
    public string MilesEventName { get; set; }
    [FieldOrder(2)]
    public string ThirdPartyEventCode { get; set; }
    [FieldOrder(3)]
    public string ThirdPartyEventName { get; set; }
    [FieldOrder(4)]
    public string ThirdPartyReasonCode { get; set; }
    [FieldOrder(5)]
    public string MilesRef { get; set; }
    [FieldOrder(6)]
    public string ThirdPartyRef { get; set; }
    [FieldOrder(7)]
    public string TrackDate { get; set; }

    [FieldOrder(8)]
    public string TrackTime { get; set; }

    [FieldOrder(9)]
    [FieldOptional]
    public string OrderNumber;

1 个答案:

答案 0 :(得分:0)

非常新手。我没看错:(

跟踪日期之后应该是

[FieldOrder(8)]
[FieldOptional]
public string TrackTime;