TheJackal
TheJackal

Reputation: 435

How to use linq and string.EndsWith(<1 of N items in an array>)

I have an expression as above in the title. Is it possible to use linq to iterate through an array and evaluate if true or not. example string[] a = {"es","ag"}

if (string.EndsWith(<1 of N items in a>)==true){//do something}

Upvotes: 3

Views: 2192

Answers (1)

It&#39;sNotALie.
It&#39;sNotALie.

Reputation: 22794

if (a.Any(yourString.EndsWith))
{
    //your string ends with one of those endings.
}

Upvotes: 6

Related Questions