Determining whether a string ends with one of a few given options I wrote the following function to determine whether a string ends with one of a few given options.

I'm sure it can be written more elegantly, probably avoiding the loop.

bool EndsWithOneOf(string value, IEnumerable&lt;string&gt; suffixes)
{ 
    foreach(var suffix in suffixes)
    {
        if value.EndsWith(suffix)
            return true;
    }
    return false;
}
You can LINQify it to improve readability:

bool endsWithOneOf = suffixes.Any(x =&gt; value.EndsWith(x));


Note that this doesn't "avoid the loop", since Any() will iterate through the suffixes (stopping when it hits a match.) But that's ok, since how else could you do it? You have an enumeration of suffixes, so to do anything with them, you must enumerate them.