Will All My Classes Look Like Records Now?

Published: 14 December 2023
on channel: Zoran Horvat
7,532
438

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? ►    • Why is C# Evolving This Way?  
Nick Chapsas: The C# 12 Feature You Shouldn’t Use, Yet ►    • 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 ►   / zoranhorvat  
✅🔔 Subscribe ►    / @zoran-horvat  
⭐ Learn more from video courses:
Beginning Object-oriented Programming with C# ► https://codinghelmet.com/go/beginning...
⭐ Collections and Generics in C# ► https://codinghelmet.com/go/collectio...
⭐ Making Your C# Code More Object-oriented ► https://codinghelmet.com/go/making-yo...
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
⭐ CONNECT WITH ME 📱👨

🌐Become a patron ►   / zoranhorvat  
🗳 Pluralsight Courses ► https://codinghelmet.com/go/pluralsight
📸 Udemy Courses ► https://codinghelmet.com/go/udemy
📸 Join me on Twitter ►   / zoranh75  
🌐 Read my Articles ► https://codinghelmet.com/articles
📸 Join me on LinkedIn ►   / zoran-horvat  
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
👨 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


Watch video Will All My Classes Look Like Records Now? online without registration, duration hours minute second in high quality. This video was added by user Zoran Horvat 14 December 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 7,53 once and liked it 43 people.