The evolution of Properties in C# from version 1 to 10



Check out my courses: https://nickchapsas.com
Become a Patreon and get source code access: https://www.patreon.com/nickchapsas

Hello everybody I’m Nick and in this video I will show you how Properties evolved in C# from the very first version until the latest C# 10 version. I will explain why they were added and what problem they were solving and take a look at how they changed throughout the years.

Timestamps
Intro – 0:00
Why do properties exist? – 0:54
C# 1 – 2:48
C# 3 – 6:23
C# 6 – 9:19
C# 7 – 11:02
C# 8 – 12:33
C# 9 – 14:06
C# 10 – 16:19
C# 9’s records – 16:49

Don’t forget to comment, like and subscribe 🙂

Social Media:
Follow me on GitHub: http://bit.ly/ChapsasGitHub
Follow me on Twitter: http://bit.ly/ChapsasTwitter
Connect on LinkedIn: http://bit.ly/ChapsasLinkedIn

Keep coding merch: https://keepcoding.shop

#csharp #dotnet

27 Comments

  1. Hi Nick, I tried this approach to create readonly properties but .Net5 DI doesn't pass anything to them. In example: public IContactsProcessService _сontactProcessService { get; init; }. Is there way throw long Ctor's and use this smart properties?

  2. Missed an analysis why these shorthands should be in language rather than some IDE macros that generate the boilerplate code. Is it really a good language principle to have as much syntax (and syntax variants) as possible to further some concept of terseness as ultimate goal? It is often implied that terseness saves time coding (but if it goes at the expense of readability and language orthogonality that is doubtful), but often many of the same goals can be achieved with some easily triggered autocompletion options in the IDE

  3. Thank you, it's a good idea to make such videos, I left this language a long time ago and when I came back to it I found a lot of changes and new features which I'm not familiar with.

  4. a field:Obsolete attribute for the backing field… why would you even do that? What purpose does this serve?
    How would you even use it since the compiler won't let you use the autogenerated backing field directly

  5. I think Pattern Matching sintax introduced on C#8 is a good option when you are comparing multiple values for the same property. At least it gives you different flavors to play around.
    So depending on the number of properties and nesting levels, you can have cleaner if statements.

    foreach (var user in users)
    {
    if (user.Birthday is { Year: 2022, Month: 03 })
    {
    Console.WriteLine(user.Name);
    }

    if (user is { Birthday: { Year: 2022, Month: 03 } })
    {
    Console.WriteLine(user.Name);
    }

    if (user is { Birthday.Year:2022, Birthday.Month: 03})
    {
    Console.WriteLine(user.Name);
    }
    }

  6. Just writing some VBA in Excel. To be easy I just declare PUBLIC vars (no PROPERTY). Why use Properties (when get/set is public) ?

  7. Very nice and instructive this historical perspectives…
    showing how and why something evolved…
    please do more of this,,,

    and I also would like to hear your opinion on what would be the next step in the topics evolution…
    or how it should evolve…

  8. Thanks for the video. I didn't know about the "is" and "not" key words. From now on, I'll use them more often, because I find them easier to read than != for example.

  9. I love your videos, learning a lot about C#, but sadly at every video I say to myself about C# …so messy! Crazy considering the C# creator knows better from his previous language, Delphi.

  10. I was hoping when C# 10 came up, you'd start with semi-auto-properties. But, after re-googling it, it seems this has been stashed for C# 11… Unfortunately.

  11. Nice, an evolution of Lists video would be cool, too. Seeing how Generics come in 2.0 and late different initializers, etc.

  12. The one thing C# hasn't assimilated is OTBS. They incorporate everything else that's good; it's time guys. Make the switch.

Leave a Reply

© 2023 53GB