C# Querying With LINQ Querying the BirdWatcher Data Extension Method

Rohit Gopalan
Rohit Gopalan
75,722 Points

Extension method in Linq

With the code below, I am not getting the correct output of False. Any suggestions to improve my code would be much appreciated.

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.Contains(source);    
        }
    }
}

1 Answer

Carling Kirk
STAFF
Carling Kirk
Treehouse Guest Teacher

Hi Rohit! The stringsToMatch should be able to be partially found in the source string. Try using a combination of the Contains method and the Any method.