- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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
- Related Articles
- C# Linq Distinct() Method
- C# Linq Where Method
- C# Linq Intersect Method
- C# Linq FirstorDefault Method
- C# Linq Reverse Method
- C# Linq Select Method
- C# Linq SelectMany Method
- C# Linq Skip() Method
- C# Linq SkipLast Method
- C# Linq Sum() Method
- C# Linq TakeWhile() Method
- C# Linq ThenBy Method
- C# Linq LastorDefault Method
- C# Linq Zip Method
- C# Linq Contains Method

Advertisements