Mega Code Archive

 
Categories / C# Book / 04 LINQ
 

0394 Contains

Input: IEnumerable<TSource> Optional lambda expression: TSource => TResult Contains returns true if the given element is present: using System; using System.Collections; using System.Collections.Generic; using System.Linq; class Program { static void Main() { bool hasAThree = new int[] { 2, 3, 4 }.Contains(3); // true; Console.WriteLine(hasAThree); } } The output: True