Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 772 Bytes

File metadata and controls

48 lines (36 loc) · 772 Bytes

^ __Back__ ^

为 C# 添加语法糖,使得可以使用 .. 来代替 Enumerable.Range 方法,以及 .. 语法糖的扩展方法.

English

Add syntactic sugar to C#, so that you can use .. instead of the Enumerable.Range method, as well as the extension method of the .. syntactic sugar.

使用方法(Usage)

// 生成 1 到 10 的序列
var range = 1..10;

foreach (var i in ..3)
{
    Console.WriteLine(i);
}
// Output: 0, 1, 2, 3

foreach (var i in 1..3)
{
    Console.WriteLine(i);
}
// Output: 1, 2, 3

foreach (var i in 3)
{
    Console.WriteLine(i);
}
// Output: 0, 1, 2, 3