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
1

1 Answer 1

0

This is one way to do it.

Map(m => m.Status).Index(0).ConvertUsing(row => ((int)row.Status).ToString());
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.