1

How can i ignore the sentence case of what is in an array when using intersect in c#? I have the following code

    var rtn = (filters == null) ? pubs : pubs.Where(
            r =>
            Get<PubDetailPage>(new ContentReference(r.PageId)).FacilitiesArray.Intersect(filters).Count() == filters.Length).ToList();

and the problem I got is that in the array called filters I have the following values (notice the sentence case) e.g

Value One Value two value Three

and in the array called FacilitiesArray (which is content managed) I have the following values (again notice the sentence case)

Value One Value Two Value Three

This will only filter back results for Value One as they match. Is there something I can use to match the values which will ignore the sentence case so no matter if value one in the filers array looked like this VaLuE oNe and value one in FacilitiesArray looked like this VALUE ONE. They would match and filter results back.

Mike G
  • 4,232
  • 9
  • 40
  • 66
Paul
  • 620
  • 11
  • 35

1 Answers1

7

Pass StringComparer.OrdinalIgnoreCase to Intersect().

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964