Primary Constructor in C# 12 Explained! 🟢 New Feature in .NET Core 8 (C#12)

Поделиться
HTML-код
  • Опубликовано: 25 июл 2024
  • Here, you will learn Primary Constructor in C# 12, Primary Constructors in C# 12 provide a new way of writing the class, struct constructor. Primary Constructors are very simple to use and provide a cleaner way to write your C# 12 code using dotnet core 8.
    📌 In this video, we will talk about :
    🟢 What are primary constructors in C#? 00:00
    🟢 Records vs. primary constructor in C# 03:28
    🟢 Assign primary constructor parameters to fields of class 04:53
    🟢 Assign primary constructor parameters to properties of class 05:34
    🟢 Apply validations on primary constructors parameters in C# 06:16
    🟢 Working with multiple constructors along with the primary constructor in C# 08:36
    🟢 Pass the parameters to parent class primary constructors (base keyword) 09:50
    🟢 Using Dependency Injections in Primary Constructors in C# 11:19
    Primary Constructors are a powerful feature introduced in C# 12. They streamline the process of initializing object properties, making your code cleaner and more concise. Whether you're creating classes for a simple application or working on a complex project, understanding Primary Constructors is crucial for efficient and maintainable code.
    👍 Don't forget to like this video if you found it helpful, and subscribe to our channel for more informative C# programming tutorials. Hit the notification bell to stay updated with our latest content.
    📢 Share this video with your fellow developers and friends who want to master C# constructors and Primary Constructors. Let's spread knowledge and empower the coding community together!
    💰 SUPPORT Nitish Kaushik ☕💳 by donating for more quality content!
    💳 Paypal: www.paypal.com/paypalme/nitishkaushik
    ☕ BuyMeACoffee: www.buymeacoffee.com/nitishkaushik
    Your support is greatly appreciated! 🙌🎥📚
    #primaryconstructor #csharp #dotnetcore #nitishkaushik
  • НаукаНаука

Комментарии • 10

  • @kaushikbhadani
    @kaushikbhadani 6 месяцев назад

    Very helpful. Thank you Nitish Kaushik!!

  • @TechLead-DOTNET
    @TechLead-DOTNET 10 месяцев назад

    Nicely Explained

  • @10Totti
    @10Totti 10 месяцев назад +1

    Best tutorial thanks!

  • @user-fqlt
    @user-fqlt 10 месяцев назад

    Thanks for the content.
    Good tutorial . +1sub

  • @MohammadNikravan
    @MohammadNikravan 8 месяцев назад +1

    Assigning the primary constructor to a fullset property results in having two fields in your class - one for the field and one for the primary constructor. Unfortunately, we can't make the generated field as read-only in the primary constructor. If we assign parameter to a property it might cause the object to consume double the memory or at least bug prone as we have to make sure which one is used in the class. If you bypass the primary constructor to the parent, the field will exist in derived class too! This feature can be quite confusing, and I wish there was an option to disable it completely to prevent our team from using it.

  • @sachinrajput4746
    @sachinrajput4746 10 месяцев назад +1

    Thank you sir.
    Very helpful video