c# check if list contains object code example
Example 1: how to check which item is in an object property c#
var matches = myList.Where(p => p.Name == nameToExtract);
Example 2: c# verify in class exist in list
Item wonderIfItsPresent = ...
bool containsItem = myList.Any(item => item.UniqueProperty == wonderIfItsPresent.UniqueProperty);'
Example 3: list contains type c#
if (within.OfType<Ball>().Any())