C# | Check if an element is in the Collection<T>
Collection<T>.Contains(T) method is used to determine whether an element is in the Collection<T>.
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:
Note: This method performs a linear search. Therefore, this method is an O(n) operation, where n is Count.
My Personal Notes arrow_drop_up
Please Login to comment...