CSharp 7.1

De Banane Atomic
Aller à la navigationAller à la recherche

Async Main

// the following methods are now allowed entrypoints:
static async Task Main() { }
static async Task Main(string[] args) { }
static async Task<int> Main() { }
static async Task<int> Main(string[] args) { }

Target-typed "default" literal

int i = default(int);
// is replaced by (its type is inferred by target-typing instead)
int i = default;

Infer tuple names

list.Select(x => (P1: x.P1, P2: x.P2));
// is replaced by (tuple names are inferred)
list.Select(x => (x.P1, x.P2));

Pattern-matching with generics

C# 7.0 Pattern matching