forked from rogerwcpt/python-linq-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
41 lines (35 loc) · 1.2 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.ComponentModel;
using System.Linq;
using linqshared;
namespace linq_generation
{
class Program : ProgramBase
{
static void Main(string[] args)
{
Linq65();
// Linq66();
}
[Category("Generation Operators")]
[Description("This sample uses generates a sequence of numbers from 100 to 149 that is used to find which numbers in that range are odd and even.")]
static void Linq65()
{
var numbers = Enumerable.Range(100, 50)
.Select(n =>
new
{
Number = n,
OddEven = n % 2 == 1 ? "odd" : "even"
});
numbers.ForEach((n) => Console.WriteLine("The number {0} is {1}.", n.Number, n.OddEven));
}
[Category("Generation Operators")]
[Description("This sample uses generates a sequence of repeated numbers that contains the number 7 ten times.")]
static void Linq66()
{
var numbers = Enumerable.Repeat(7, 10);
numbers.ForEach(Console.WriteLine);
}
}
}