The Count method returns the count of elements in a sequence.
Let us first set an array.
string[] arr = { "Java", "C++", "Python"};Now, use the Count() method to count the array elements.
arr.AsQueryable().Count();
The following is the complete example.
Example
using System;
using System.Linq;
using System.Collections.Generic;
class Demo {
static void Main() {
string[] arr = { "Java", "C++", "Python"};
int arr_count = arr.AsQueryable().Count();
Console.WriteLine("Count of arrays: {0}", arr_count);
}
}Output
Count of arrays: 3