Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Querying With LINQ Querying the BirdWatcher Data Extension Method

Emilio Meira
Emilio Meira
11,059 Points

Problems on the Linq query

I'm not sure what I'm doing wrong here, guys. The return is not matching the correct contains.

ContainsAnyExtension.cs
using System.Collections.Generic;
using System.Linq;

namespace Treehouse.CodeChallenges
{
    public static class ContainsAnyExtension
    {
        public static bool ContainsAny(this string source, IEnumerable<string> stringsToMatch)
        {
            return stringsToMatch.Any(b => b.Contains(source));
        }
    }
}

1 Answer

Steven Parker
Steven Parker
231,275 Points

It looks like your arguments are reversed.

Remember, you're trying to see if any of the strings to match can be found in the source. So instead of b.Contains(source), you probably meant to write source.Contains(b).

Emilio Meira
Emilio Meira
11,059 Points

Arrrgghhh! You're so right! Thanks, man! :D