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
Return the total elements in a sequence as a 64-bit signed integer in C#
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
Advertisements