« CSharp 7.1 » : différence entre les versions
De Banane Atomic
Aller à la navigationAller à la recherche
Aucun résumé des modifications |
|||
(3 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 8 : | Ligne 8 : | ||
static async Task<int> Main(string[] args) { } | static async Task<int> Main(string[] args) { } | ||
</filebox> | </filebox> | ||
= [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.1/target-typed-default Target-typed "default" literal] = | |||
<kode lang='cs'> | |||
int i = default(int); | |||
// is replaced by (its type is inferred by target-typing instead) | |||
int i = default; | |||
</kode> | |||
= [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.1/infer-tuple-names Infer tuple names] = | |||
<kode lang='cs'> | |||
list.Select(x => (P1: x.P1, P2: x.P2)); | |||
// is replaced by (tuple names are inferred) | |||
list.Select(x => (x.P1, x.P2)); | |||
</kode> | |||
= [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.1/generics-pattern-match Pattern-matching with generics] = | |||
[[CSharp_7#Pattern_matching|C# 7.0 Pattern matching]] |
Dernière version du 15 décembre 2021 à 16:50
Async Main
Program.cs |
// 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)); |