fixes
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<LangVersion>preview</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -22,12 +22,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
// Positional pattern (using a tuple - hence "tuple pattern")
|
// This is a tuple, supported since C# 7
|
||||||
// Important: this works with any deconstructable type!
|
|
||||||
(string, string) personInfo = ("Oli", "Sturm");
|
(string, string) personInfo = ("Oli", "Sturm");
|
||||||
var (firstName, lastName) = personInfo;
|
var (firstName, lastName) = personInfo;
|
||||||
// firstName ist jetzt "Oli" und lastName ist "Sturm"
|
// 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:
|
// Nested property patterns:
|
||||||
var customer = new Customer
|
var customer = new Customer
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user