C# 12 Primary Constructors

preview_player
Показать описание
Getting bored of having to write code in triplicate just to initialize a field? Try primary constructors.

Source code available at:

Related videos:

Topics include:
- TypeScript parameter properties
- Primary constructors in records
- Calling primary constructors
- Primary constructors in classes and structs
- Using Primary constructor fields in classes
- When not to use primary constructors
- Primary constructors and dependency injection
- Primary constructors and readonly fields
- Overloading primary constructors
Рекомендации по теме
Комментарии
Автор

Do think the drawbacks of primary constructors (like missing 'readonly') outweigh the benefits? Leave a comment.
And if you liked the video, click the 👍.

CodingTutorialsAreGo
Автор

At this moment primary constructors feature looks a bit unfinished, I hope they will properly implement it in the next version. Thanks for the video!

DNI
Автор

This is a nice observation of these couple of C# features. Will you be doing a review of any .NET 8 or other C#12 aspects?

zaharivaklinov