This commit is contained in:
Oli Sturm
2022-05-12 16:35:34 +01:00
parent eecba258b3
commit 0a28574514
3 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
Address = new Address { City = "Castle Douglas", Country = "UK" } Address = new Address { City = "Castle Douglas", Country = "UK" }
}; };
if (customer is { Address.City: "Castle Douglas" }) { if (customer is { Address.City: "Castle Douglas" }) {
Console.WriteLine("Dieser Kunde wohnt gleich um die Ecke"); Console.WriteLine("This customer lives around the corner");
} }
} }
} }
+2 -2
View File
@@ -5,7 +5,7 @@
{ {
1 => 2, 1 => 2,
2 => 3, 2 => 3,
_ => throw new ArgumentException("Weiter geht's nicht") _ => throw new ArgumentException("Rien ne va plus")
}; };
// Property Pattern: // Property Pattern:
@@ -34,7 +34,7 @@
Address = new Address { City = "Castle Douglas", Country = "UK" } Address = new Address { City = "Castle Douglas", Country = "UK" }
}; };
if (customer is { Address: { City: "Castle Douglas" } }) { if (customer is { Address: { City: "Castle Douglas" } }) {
Console.WriteLine("Dieser Kunde wohnt gleich um die Ecke"); Console.WriteLine("This customer lives around the corner");
} }
} }
} }
+7
View File
@@ -20,6 +20,13 @@
} }
} }
public enum OrderValue {
ValuableDueToHighCount,
ValuableDueToHighItemPrice,
ValuableDueToHighTotal,
NotValuable,
}
// Positional patterns with placeholders - note that // Positional patterns with placeholders - note that
// the element lists must be "complete"! // the element lists must be "complete"!
static OrderValue OrderValueCategory(Order o) => static OrderValue OrderValueCategory(Order o) =>