0

I'm using CsvHelper to write into csv file.
I want to write ENUM as int, not string.

What is the eassiesest way to do this?
Assuming I have some types of ENUM's, not just one.

    public enum EStatus
    {
        ES_FAILED = 0,
        ES_DONE,
        ES_UNKNOWN
    }

Map(m => m.status).Index(0)

output:

ES_DONE

Expected:

1
rety
  • 59
  • 1
  • 6
  • 2
    Does this answer your question? [How to use EnumConverter with CsvHelper](https://stackoverflow.com/questions/31666915/how-to-use-enumconverter-with-csvhelper) – smolchanovsky Feb 02 '20 at 16:18

1 Answers1

0

This is one way to do it.

Map(m => m.Status).Index(0).ConvertUsing(row => ((int)row.Status).ToString());
David Specht
  • 7,784
  • 1
  • 22
  • 30