Search code examples
.netcsvhelper

Is is possible to serialize fields (not just properties) with CsvHelper?


I'm using CsvHelper but I'd like to be able to serialize fields and not just properties. Is there a way to do this?

Note that this is hard to search for, because the documentation uses the word "Field" to mean a class property, but I'm talking about an actual class field, that is, MyIntField in this class:

class Something
{
    public int MyIntProperty {get; set;}
    public int MyIntField;
}

Solution

  • No, it is not currently possible. You get an error message

    'MyIntField' is not a property. Did you try to map a field by accident?