C# 12 Primary Constructors

Поділитися
Вставка
  • Опубліковано 15 жов 2024
  • Getting bored of having to write code in triplicate just to initialize a field? Try primary constructors.
    Source code available at:
    github.com/Jas...
    Related videos:
    C#9 Records • C# 9 Records
    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

КОМЕНТАРІ • 6

  • @CodingTutorialsAreGo
    @CodingTutorialsAreGo  10 місяців тому +4

    Do think the drawbacks of primary constructors (like missing 'readonly') outweigh the benefits? Leave a comment.
    Source code available at: github.com/JasperKent/Primary-Constructors
    Remember to subscribe at ua-cam.com/channels/qWQzlUDdllnLmtgfSgYTCA.html
    And if you liked the video, click the 👍.

  • @abdelazizshaban5190
    @abdelazizshaban5190 4 місяці тому +1

    You're underrated, Thank you

  • @zaharivaklinov
    @zaharivaklinov 10 місяців тому +5

    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?

  • @DNI404
    @DNI404 10 місяців тому +3

    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!

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  10 місяців тому +2

      I’m finding that for other features too. Next week’s video highlights a big performance problem with the new spread operator.