LongCount
In this chapter you will learn:
Get to know LongCount operator
LongCount
returns an long type value that represents the total number of elements in a sequence.
using System;/* j a v a2 s.co m*/
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
public static void Main() {
string[] fruits = { "apple", "banana", "mango",
"orange", "passionfruit", "java2s.com" };
long count = fruits.LongCount();
Console.WriteLine("There are {0} fruits in the collection.", count);
}
}
LongCount filter delegate
using System;/*from j a v a 2s . co m*/
using System.Linq;
public class MainClass {
public static void Main() {
int[] intArray= { 1,2,3,4,5,6,7,8,9};
long count = fruits.LongCount(n => n > 1 && n < 4);
Console.WriteLine(count);
}
}
Next chapter...
What you will learn in the next chapter:
- How to use Max operator
- Max with filter delegate
- Max among string array
- Max for custom types
- How to get the longest word
Home » C# Tutorial » Linq Operators