C# non-vowel words


I want an extension method that needs to return non-vowel words.I designed

 public static IEnumerable<T> NonVowelWords<T>(this IEnumerable<T> word)
        return word.Any(w => w.Contains("aeiou"));

I received error as "T" does not contain extanesion method "Contains".

Best Solution

You don't need to use a generic method if you're always dealing with strings.

public static IEnumerable<string> NonVowelWords(this IEnumerable<string> words)
    char[] vowels = { 'a', 'e', 'i', 'o', 'u' };

    return words.Where(w => w.IndexOfAny(vowels) == -1);