In LINQ, quantifier operators are used to returning a boolean value which shows that whether some or all elements satisfies the given condition. The Standard Query Operator supports 3 different types of quantifier operators:
The Contains operator is used to check whether the given sequence or collection contains the specified element or not. It will return true if the given sequence contains the specified element, otherwise, return false. It is overloaded in two different types:
- Contains<TSource>(IEnumerable<TSource>, TSource): This method is used to check whether a sequence contains a specified element by using the default equality comparer.
- Contains<TSource>(IEnumerable<TSource>, TSource, IEqualityComparer<TSource>): This method is used to check whether a sequence contains a specified element by using a specified IEqualityComparer.
- It does not support query syntax in C# and VB.Net languages.
- It support method syntax in both C# and VB.Net languages.
- It present in both the Queryable and Enumerable class.
- It will throw ArgumentNullException if the given source is null.
- It does not return value instead of this it return true or false.
- The return type of this operator is System.Boolean.
- You can use custom class that derives IEqualityOperator with Contains to check for the object in the given collection.
Result: True Result: False
Employee Found?: False
- LINQ | Quantifier Operator | All
- LINQ | Quantifier Operator | Any
- LINQ | Set Operator | Except
- LINQ | Element Operator | First
- LINQ | Element Operator | Last
- LINQ | Partition Operator | Take
- LINQ | Filtering Operator | where
- LINQ | Set Operator | Distinct
- LINQ | Set Operator | Union
- LINQ | Set Operator | Intersect
- LINQ | Sorting Operator | OrderBy
- LINQ | Partition Operator | Skip
- LINQ | Element Operator | ElementAtOrDefault
- LINQ | Element Operator | ElementAt
- LINQ | Partition Operator | SkipWhile
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.