You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Primary constructors were introduced in C# 12, we should consider replacing the normal flow of adding a ctor in order to initialize fields. This would reduce some visual noise, just need to be aware of double capturing.
With primary constructors, AKA parameters for classes, we would be able to do:
Primary constructors were introduced in C# 12, we should consider replacing the normal flow of adding a ctor in order to initialize fields. This would reduce some visual noise, just need to be aware of double capturing.
With primary constructors, AKA parameters for classes, we would be able to do:
this
instead of
The only issue is that primary constructors params can't be
readonly
, the solution would be to choose one option:private readonly
field, still reducing code by removing the ctor.My purist side says "initialize the readonly fields", while my practical side says to just ignore it. What do you think?
The text was updated successfully, but these errors were encountered: