C# 12 has introduced primary constructors - a reasonably small feature, but the one that has already stirred up the community. What makes them so controversial?
There are several details to sort out before you can understand the role of primary constructors. One is that primary constructors are indeed just a minor feature. Don't expect much from them!
Another question is that of the connection with record types. Did you know primary constructors have existed in C# since version 9? They are an integral part of records, where a primary constructor is used to initialize the required components of the object.
That gives us the direction to think when applying a primary constructor to a custom class: Use it to indicate the required components assigned to properties, and you will be safe!
Contrary to that, if you rely on more advanced abilities of the primary constructor's parameters, such as their scope and even mutability, you will need more than a pair of eyes to keep your code from bugs.
Watch this video to learn the pros and cons of the primary constructors in C# 12. Learn the safe and reasonable use for them and a few pitfalls to avoid.
Watch related videos:
Why is C# Evolving This Way? ► [ Ссылка ]
Nick Chapsas: The C# 12 Feature You Shouldn’t Use, Yet ► [ Ссылка ]
Thank you so much for watching! Please like, comment & share this video as it helps me a ton!! Don't forget to subscribe to my channel for more amazing videos and make sure to hit the bell icon to never miss any updates.🔥❤️
✅🔔 Become a patron ► [ Ссылка ]
✅🔔 Subscribe ► [ Ссылка ]
⭐ Learn more from video courses:
Beginning Object-oriented Programming with C# ► [ Ссылка ]
⭐ Collections and Generics in C# ► [ Ссылка ]
⭐ Making Your C# Code More Object-oriented ► [ Ссылка ]
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
⭐ CONNECT WITH ME 📱👨
🌐Become a patron ► [ Ссылка ]
🗳 Pluralsight Courses ► [ Ссылка ]
📸 Udemy Courses ► [ Ссылка ]
📸 Join me on Twitter ► [ Ссылка ]
🌐 Read my Articles ► [ Ссылка ]
📸 Join me on LinkedIn ► [ Ссылка ]
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
👨 About Me 👨
Hi, I’m Zoran, I have more than 20 years of experience as a software developer, architect, team lead, and more. I have been programming in C# since its inception in the early 2000s. Since 2017 I have started publishing professional video courses at Pluralsight and Udemy and by this point, there are over 100 hours of the highest-quality videos you can watch on those platforms. On my YouTube channel, you can find shorter video forms focused on clarifying practical issues in coding, design, and architecture of .NET applications.❤️
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
⚡️RIGHT NOTICE:
The Copyright Laws of the United States recognize a “fair use” of copyrighted content. Section 107 of the U.S. Copyright Act states: “Notwithstanding the provisions of sections 106 and 106A, the fair use of a copyrighted work, including such use by reproduction in copies or phono records or by any other means specified by that section, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright." This video and our youtube channel, in general, may contain certain copyrighted works that were not specifically authorized to be used by the copyright holder(s), but which we believe in good faith are protected by federal law and the Fair use doctrine for one or more of the reasons noted above.
#csharp #dotnet #objectorientedprogramming
Ещё видео!