When using the FileHelpers library I am getting a NullReferenceException when trying to write a .csv file.
I have narrowed the problem down. Whenever I have a null decimal? it throws this exception. It works fine on reading, just not writing.
I have included a sample that shows the same problem as my app:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args) {
rec record = new rec { id = 1, mydecimal = null };
List<rec> records = new List<rec> { record };
FileHelpers.FileHelperEngine<rec> engine = new FileHelpers.FileHelperEngine<rec>();
Console.WriteLine(engine.WriteString(records));
}
}
[FileHelpers.DelimitedRecord(",")]
public class rec
{
public int id;
public decimal? mydecimal;
}
}