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
155,584 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