Check elements in list : Contains() method



How to check elements in list in c#?

Contains() method is used to determine whether an element is persent in the List or not. It returns bool.

Example:

var checkMarks = new List<int>(){ 52, 12, 85, 36, 98 };
checkMarks.Contains(85); // returns true
checkMarks.Contains(11); // returns false
checkMarks.Contains(98); // returns true

0 Comment's

Comment Form

Submit Comment