Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Linq Count method
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
Advertisements