From a2d1e4adc234d370b373707dd6a6ee15a92c1165 Mon Sep 17 00:00:00 2001 From: Oli Sturm Date: Fri, 21 Oct 2022 13:17:37 +0100 Subject: [PATCH] fixes --- samples/CS11/CS11.csproj | 1 + samples/CS8/Program.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/samples/CS11/CS11.csproj b/samples/CS11/CS11.csproj index d439800..43323f1 100644 --- a/samples/CS11/CS11.csproj +++ b/samples/CS11/CS11.csproj @@ -5,6 +5,7 @@ net7.0 enable enable + preview diff --git a/samples/CS8/Program.cs b/samples/CS8/Program.cs index 6eb5438..5e68f0d 100644 --- a/samples/CS8/Program.cs +++ b/samples/CS8/Program.cs @@ -22,12 +22,16 @@ } static void Main(string[] args) { - // Positional pattern (using a tuple - hence "tuple pattern") - // Important: this works with any deconstructable type! + // This is a tuple, supported since C# 7 (string, string) personInfo = ("Oli", "Sturm"); var (firstName, lastName) = personInfo; // firstName ist jetzt "Oli" und lastName ist "Sturm" + // Positional pattern (using a tuple - hence "tuple pattern" in this special case) + // Important: this works with any deconstructable type! Example coming up in CS9 sample. + if (personInfo is ("Oli", var olisLastName)) + Console.WriteLine($"Found Oli, his last name is {olisLastName}."); + // Nested property patterns: var customer = new Customer {