SortedSetnumbers = new SortedSet { 1, 2, 3, 4, 5 }; bool hasEvenNumbers = numbers.Any(x => x % 2 == 0);
using System.Linq; SortedSetIn this example, we create a SortedSet of strings and check if it contains any element whose length is greater than 6. We use the System.Linq namespace to access the Any method. The result is stored in the hasLongWord boolean variable, which is false in this case. The SortedSet class is part of the System.Collections.Generic namespace in the .NET Framework.words = new SortedSet { "apple", "banana", "cherry" }; bool hasLongWord = words.Any(x => x.Length > 6);