1

I have to import a file that have an amount in the following format:

Id    Amount
101   123456 
102   456789

I'm using FileHelpers library with [FieldConverter(ConverterKind.Decimal)] attribute but it converts the amount into this:

12356 --> $123456

I want it to apply last two digits to the decimals. I want it to look like this:

123456 --> $1234.56
456789 --> $4567.89

Any ideas? Thanks.

UPDATE: I came up with my own solution. I've created a separate field called Amount that calculates the payment amount based on the the amount provided in file, which is parsed into the private variable called AmountRaw.

[DelimitedRecord(",")]
public class PaymentFileRecord
{
    public int PaymentId;

    [FieldConverter(ConverterKind.Date, "yyyyMMdd")]
    public DateTime PaymentDate;

    [FieldConverter(ConverterKind.Decimal)]
    private decimal AmountRaw;

    public decimal Amount
    {
        get { return AmountRaw / 100; }
    }
}
4

1 回答 1

1

试试这个:将你收到的数字除以 100。

于 2016-05-12T11:17:26.530 回答