3 ways to query by using LINQ to Objects

Akiii
Posted by Akiii under LINQ category on | Points: 40 | Views : 1407
Hi friends,

Today, I will show you 3 ways to query by using LINQ to Objects .

First we will declare and define an Array:-
int[] numbersArray = { 1, 2, 3, 4, 5};


1st way:-

IEnumerable<int> result = from tempvar in numbersArray
select tempvar;


2nd way(using Lambda Expression) :-

IEnumerable<int> result = numbersArray.Select(p => p);



3rd way(using Anonymous Delegate) :-

IEnumerable<int> evens = numbersArray
.Select(delegate(int x) { return (x); });




Thanks and Regards
Akiii

Comments or Responses

Posted by: Sheonarayan on: 3/16/2012 Level:HonoraryPlatinum | Status: [Administrator] | Points: 10
Good stuffs :)
Posted by: Akiii on: 3/16/2012 Level:Bronze | Status: [Member] | Points: 10
Thank you Sir..


Regards
Akiii

Login to post response