Use the Linq LongCount method to get the count of elements.
The following is our string array −
string[] emp = { "Jack", "Mark"};Now, use the LongCount() method.
emp.AsQueryable().LongCount();
Here is the complete code.
Example
using System;
using System.Collections.Generic;
using System.Linq;
class Demo {
static void Main() {
string[] emp = { "Jack", "Mark"};
long res = emp.AsQueryable().LongCount();
Console.WriteLine("{0} employees in the Department", res);
}
}Output
2 employees in the Department