Select - Simple
This sample prints a integers Hundred greater than those in an input array. The sample uses the expression in the select clause to add hundred to each element in the new sequence.
public void Linqsample()
{
int[] numbers = { 500, 400, 100, 300, 900, 800, 600, 700, 200, 000 };
var numsPlusOne = from n in numbers
select n + 100;
Console.WriteLine("Numbers + 100:");
foreach (var i in numsPlusHundred)
{ Console.WriteLine(i); }
}
Result
Numbers + 1:
600
500
200
400
1000
900
700
800
300
100
No comments:
Post a Comment