Select - Simple 1

Query
public void Linq6()
{
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

var numsPlusOne =
from n in numbers
select n + 1;

Console.WriteLine("Numbers + 1:");
foreach (var i in numsPlusOne)
{
Console.WriteLine(i);
}
}
Lambda Expression
public void DataSetLinq6()
{
var numbers = testDS.Tables["Numbers"].AsEnumerable();

var numsPlusOne = numbers.Select(n => n.Field(0) + 1);

Console.WriteLine("Numbers + 1:");
foreach (var i in numsPlusOne)
{
Console.WriteLine(i);
}
}
Output
Numbers + 1:
6
5
2
4
10
9
7
8
3
1
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +