publicdoubleGetArea(double radius { return PI * Pow(radius, 2); }
Await in Catch and Finally Blocks
Extension Add in Collection Initializers
C# 7.0
Improvements to the Tuple Class
var newTuple = new Tuple<string, decimal, bool>(Name: "A", OrderTotal: 123, IsVIP: true);
Inline output variable
if (int.TryParse("123", out var i)
{
}
Pattern matching in ‘switch’
public string SuggestAnAction2(Bird bird) {
switch (bird):
{
case Magpie m when m.IsSwoopingSeason == true:
return "Bring a helmet";
case Magpie m when m.IsSwoppingSeason == false:
return "Go for a stroll";
case Budgie b:
return $"Bring {b.FavouriteFood} for the walk";
case null:
throw new ArgumentNullException(nameof(bird));
default:
return "Do nothing"
}
}