Firstly, set a string array.
string[] num = { "One", "Two", "Three", "Four", "Five"};Use the Linq LongCount method to get the count of elements.
num.AsQueryable().LongCount();
Here is the complete code −
Example
using System;
using System.Collections.Generic;
using System.Linq;
class Demo {
static void Main() {
string[] num = { "One", "Two", "Three", "Four", "Five"};
long res = num.AsQueryable().LongCount();
Console.WriteLine("{0} elements", res);
}
}Output
5 elements