Is it possible to add a $ to a field using FileHelpers library? I have an object
[DelimitedRecord("|")]
public class TradesToBloombergFileHeaders
{
[FieldOrder(1)]
public Guid id;
[FieldOrder(2)]
public string name;
[FieldOrder(3)]
public double price;
[FieldOrder(4), FieldConverter(ConverterKind.Date, "yyyyMMdd")]
public DateTime date;
}
I'm generating a file and want price to be in this format $xxx.xx. Is it even possible? I searched, read documentaion and I don't see anything similar to what i need. Thanks!
Probably the attributes:
will do that for you. As you see I changed the type to
decimal
which is better for prices/money.See Standard Numeric Format Strings and
ConverterKind
enum.Actually I have never used FileHelpers. The page Arguments for the Default Converters of the library seems to indicate that I cannot use a standard format string like
"C"
above. If that is the case, try to imitate the example from Decimal Custom Converter instead, perhaps?