New features for those who haven’t seen them:

// Primary constructors
public class NamedItem(string name)
{
    public string Name => name;
}

// Default lambda params
var IncrementBy = 
    (int source, int increment = 1) => 
        source + increment;

Console.WriteLine(IncrementBy(5)); // 6
Console.WriteLine(IncrementBy(5, 2)); // 7

// Type aliases
using Point = (int x, int y);
  • starmanOP
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 years ago

    I heard that unions won’t be implemented in C# 12, unfortunately

    • dazfuller@kbin.social
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

      I heard the same. The number of places I want to use something like an Option<T> instead of having to consider null values… One day though