2 added 1 character in body; edited title
source | link

How to improve this code? 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 avoingavoiding the loop.

bool EndsWithOneOf(string value, IEnumerable<string> suffixes)
{ 
    foreach(var suffix in suffixes)
    {
        if value.EndsWith(suffix)
            return true;
    }
    return false;
}

How to improve this code?

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 avoing the loop.

bool EndsWithOneOf(string value, IEnumerable<string> suffixes)
{ 
    foreach(var suffix in suffixes)
    {
        if value.EndsWith(suffix)
            return true;
    }
    return false;
}

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<string> suffixes)
{ 
    foreach(var suffix in suffixes)
    {
        if value.EndsWith(suffix)
            return true;
    }
    return false;
}
    Tweeted twitter.com/#!/StackCodeReview/status/104442595224190976
    Post Migrated Here from stackoverflow.com
1
source | link

How to improve this code?

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 avoing the loop.

bool EndsWithOneOf(string value, IEnumerable<string> suffixes)
{ 
    foreach(var suffix in suffixes)
    {
        if value.EndsWith(suffix)
            return true;
    }
    return false;
}