DavidAJohn / FotoStorio

Blazor WebAssembly application for a fictional photography store, with Stripe Elements payment integration and styling with Tailwind CSS.
MIT License
5 stars 1 forks source link

C#12 Primary Constructors #28

Open DavidAJohn opened 11 months ago

DavidAJohn commented 11 months ago

Primary constructors are a long-overdue addition to C#, as of version 12.

Where there is only one constructor declared (and that is most types in FotoStorio), there is now a simplified syntax available. So let's get to work.

Here's a Microsoft guide: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/primary-constructors

Microsoft's motivation is described thus: "The ability of a class or struct in C# to have more than one constructor provides for generality, but at the expense of some tedium in the declaration syntax (my emphasis), because the constructor input and the class state need to be cleanly separated."