Posts

Showing posts from May, 2020

9 things about C# 9

Init  Introducing an  init  which is variant of  set  can only be called during object initialization: public class Employee { public string Name { get ; init ; } public string Designation { get ; init ; } } Because  init  accessors can only be called during initialization, they are allowed to mutate  readonly  fields of the enclosing class public class Employee { private readonly string name ; private readonly string designation ; public string Name { get => name ; init => name = (value ??                     throw new ArgumentNullException(nameof(Name))); } public string Designation { get => designation ; init => designation = (value ??                     throw new ArgumentNullExcept...