The Evolution of C# Constructors
C# 12 introduces a new syntax to declare class constructors with Primary Constructors . That's why I thought that it's a good time to look back at the...
C# 12 introduces a new syntax to declare class constructors with Primary Constructors. That's why I thought that it's a good time to look back at the evolution of C# constructors. Starting from the most basic constructor that most of us are familiar with, to the newer variations that were added in latest the C# versions.
Person.tspublicclassPerson{publiclongId{get;}publicstringName{get;}publicPerson(intid,stringname){=;=;}}
Person.tspublicclassPerson{publiclongId{get;}publicstringName{get;}publicPerson(intid,stringname)=>(,)=(,);}
Person.tspublicclassPerson{publicrequiredlongId{get;init;}publicrequiredstringName{get;init;}}
Person.tspublicclassPerson(longid,stringname){publiclongId{get;}=;publicstringName{get;}=;}
Feel free to update this developer bit on GitHub, thanks in advance!