This commit is contained in:
Oli Sturm
2022-02-17 16:07:37 +00:00
commit eecba258b3
13 changed files with 596 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+25
View File
@@ -0,0 +1,25 @@
namespace CS10 {
class Program {
// Nested types, just like the C# 8 sample:
public class Address {
public string? City { get; set; }
public string? Country { get; set; }
}
public class Customer {
// ...
public Address? Address { get; set; }
}
static void Main(string[] args) {
// Nested property patterns, now shorter:
var customer = new Customer
{
Address = new Address { City = "Castle Douglas", Country = "UK" }
};
if (customer is { Address.City: "Castle Douglas" }) {
Console.WriteLine("Dieser Kunde wohnt gleich um die Ecke");
}
}
}
}