c# check if list contains string code example Example: list contains type c# if (within.OfType<Ball>().Any())