syntax of contains in c# example check in list
Example 1: c# object list contaion parameters
public class A { public int Id { get; set; } public A(int id) { Id = id; } }
List<A> list = new List<A>() { new A() { Id = 1}, new A() { Id = 2} };
var matches = list.Where(item => item.Id == 1 || item.Id == 2);
// matches = [0, 1]
// can be used like
for (int i = 0; i < matches.Count; i++) { Console.WriteLine(list[i]); }
Example 2: list contains type c#
if (within.OfType<Ball>().Any())