34
1
// @nuget: FluentAssertions
2
3
using System;
4
5
namespace Try_More_On_IEnumerable
6
{
7
class Program
8
{
9
static void Main(string[] args)
10
{
11
T04Linq产生数值.Run();
12
Console.WriteLine($"运行成功,{DateTime.Now:O}");
13
}
14
}
15
}
16
17
namespace Try_More_On_IEnumerable
18
{
19
using System.Linq;
20
using FluentAssertions;
21
22
public class T04Linq产生数值
23
{
24
public static void Run()
25
{
26
// 系统内置了一个方法来获取数字的自增序列,因此可以如此简化
27
var result = Enumerable
28
.Range(0, 11)
29
.Where(x => x % 2 == 0);
30
31
result.Should().Equal(0, 2, 4, 6, 8, 10);
32
}
33
}
34
}
Cached Result