Introducing C# 10

var all the way

var f = Console.WriteLine;
var f = x => x; // inferring the return type
var f = (string x) => x; // inferring the signature
var f = [NotNull] x => x; // adding attributes on parameters
var f = [NotNull] (int x) => x;
var f = [return: NotNull] static x => x; // adding attribute for a return type
var f = T () => default; // explicit return type
var f = ref int (ref int x) => ref x; // using ref on structs
var f = int (x) => x; // explicitly specifying the return type of an implicit input
var f = static void (_) => Console.Write("Help");
4 Likes