Do LongCount with condition in CSharp

Description

The following code shows how to do LongCount with condition.

Example


/*ww  w  . j a  va  2s  . c  om*/
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class MainClass {
    public static void Main() {
        long count = Enumerable.Range(0, int.MaxValue).
        Concat(Enumerable.Range(0, int.MaxValue)).LongCount(n => n > 1 && n < 4);
        Console.WriteLine(count);
    }
}




















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ