Listnumbers = new List { 2, 4, 7, 8, 10 }; bool hasOdd = numbers.Any(x => x % 2 == 1); Console.WriteLine(hasOdd); // Output: True
ListIn this example, we use the lambda expression `x => x.Contains("animal")` to check if any of the strings in the `words` list contain the word "animal". Since none of the strings contain that word, `containsAnimal` is set to `false`. The Groups Any method is part of the System.Linq package library in C#.words = new List { "cat", "dog", "bird", "elephant", "giraffe" }; bool containsAnimal = words.Any(x => x.Contains("animal")); Console.WriteLine(containsAnimal); // Output: False