VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-check-if-an-element-is-in-the-collectiont/

⇱ C# | Check if an element is in the Collection<T> - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Check if an element is in the Collection<T>

Last Updated : 11 Jul, 2025
Collection<T>.Contains(T) method is used to determine whether an element is in the Collection<T>. Syntax:
public bool Contains (T item);
Here, item is the object to locate in the Collection<T>. The value can be null for reference types. Return Value: This method return True if item is found in the Collection<T>, otherwise, False. Below given are some examples to understand the implementation in a better way: Example 1: Output:
True
Example 2:
Output:
False
Note: This method performs a linear search. Therefore, this method is an O(n) operation, where n is Count. Reference:
Comment

Explore