TakeWhile and Take functions

Posted by Ddd under LINQ category on | Points: 40 | Views : 1830
//TakeWhile is used to evaluate on the basis of some condition by using a Lambda expression.
//In this example, numbers less than 40 will be evalued till 40 is found. after 40, the numbers < 40
//will be ignored

//Take is just used to evaluate the data (say how many values) from any given point in the array.

using System;
using System.Linq;

class opr
static void Main()
int[] arr={10, 25,20,30,38,40,39,35,65};
var p=arr.TakeWhile(a=>a<40);
foreach(var z in p)
var t=arr.Take(3);
foreach(var s in t)

Comments or Responses

Login to post response