Primary constructors in C# sees params added to a class

Published: 12 October 2023
on channel: Round The Code
2,417
68

Primary constructors are one of the new C# 12 features.

It allows you to add parameters to a class and therefore override the default behaviour of initialising a class.

The aim of this feature is to reduce code bloat and can also be used with dependency injection.

We'll show you how to add primary constructors to a class, what happens when you add a constructor alongside primary constructors, and how it can be used with dependency injection.

📖 Learn .NET and C# with our online courses 📖
https://www.roundthecode.com/dotnet-c...

👨‍💻Take our .NET and C# coding challenges👨‍💻
https://www.roundthecode.com/dotnet-c...

► More information:
https://www.roundthecode.com/dotnet-t...

🎥 Playlist 🎥
   • .NET 8 and C# 12 new features  

► Chapters
0:00 What are primary constructors?
0:25 Coding challenges
0:35 Current default constructor
0:54 Parameter constructor
1:41 Define primary constructor
2:44 Primary constructors in dependency injection
3:09 Reminder of primary constructors
3:19 Review of primary constructors

#csharp #csharpprogramming #csharpdotnet


Watch video Primary constructors in C# sees params added to a class online without registration, duration hours minute second in high quality. This video was added by user Round The Code 12 October 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 2,417 once and liked it 68 people.