How to count the items in a list using LINQ in C#

1 Answer

0 votes
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main() {
        var list = new List<int> { 3, 7, 8, 91, 99, 0, -5, 1, 2 };

        var result = list.Count();
        
        Console.WriteLine(result);
    }
}



/*
run:
   
9
 
*/

 



answered Jul 4, 2023 by avibootz
...