2 added 1 character in body; edited title

# 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;
}

Post Migrated Here from stackoverflow.com
1

# 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;
}