Contains, Any return a bool value

image_pdfimage_print
   
 

using System;
using System.Collections.Generic;
using System.Linq;
public class MainClass {
    public static void Main() {
        int[] numbers = { 10, 9, 8, 7, 6 };
        bool hasTheNumberNine = numbers.Contains(9);          // true
        bool hasMoreThanZeroElements = numbers.Any();          // true
        bool hasAnOddElement = numbers.Any(n => n % 2 == 1);  // true
    }
}

    


This entry was posted in LINQ. Bookmark the permalink.