Csvhelper: How to ignore case in latest version?

Created on 7 Dec 2018  路  6Comments  路  Source: JoshClose/CsvHelper

This no longer works for me:

// Ignore case
csv.Configuration.PrepareHeaderForMatch = header => header.ToLower();

It appears that PrepareHeaderForMatch used to be:

Func<string, string> PrepareHeaderForMatch { get; set; }

but it's now:

Func<string, int, string> PrepareHeaderForMatch { get; set; }

I wish I knew more, but it just tells me this delegate does not accept one argument.

documentation

Most helpful comment

The second argument is the index position of the header that is being passed in. Change to:

csv.Configuration.PrepareHeaderForMatch = (header, index) => header.ToLower();

I will add the names of the arguments to the Intellisense description.

All 6 comments

The second argument is the index position of the header that is being passed in. Change to:

csv.Configuration.PrepareHeaderForMatch = (header, index) => header.ToLower();

I will add the names of the arguments to the Intellisense description.

Can't this be implemented in a way that both the new and the old way work? This way by updating, not everyone's code breaks

That's why there was a major version number change. There were some other breaking changes in that release also.

Not sure if there was a non-breaking way to do it since it's a property. If it was a method, an overload could have been created, or a default parameter, but not with a property.

@JoshClose could you update your Getting Started section?
Still has this:
csv.Configuration.PrepareHeaderForMatch = (string header) => header.ToLower();

@Lroca88 updated

@JoshClose Docs have been updated and this issue can be closed.

Was this page helpful?
0 / 5 - 0 ratings