Ask HN: Modern C# book for experienced developers?

I worked with C# about 15 years ago. Due to some circumstances at work, I have the opportunity to use it again.

What are some great books that could help me learn to write *modern* C#?

I will mostly work with web and .NET Core, are there books specifically about using .NET Core on Linux?

30 points | by Fire-Dragon-DoL 2 days ago

5 comments

  • CrimsonCape 4 hours ago
    I been using C# since .Net Framework 4.6, jumped to .Net 6, and have kept up to .Net 9 when starting new projects.

    My advice is to download .Net 9 SDK because it's now super easy to create a file with extension .cs, put your terminal window next to your code, and call `dotnet run file.cs` and it just works. The compiler will teach you a lot because the errors are extremely easy to follow.

    I never bought into books because too many language features have been added in the past years that improve on "old" ways.

    The only complaint I have is that Google is still the best interface for navigating the docs. Spamming google over and over. Solving this in an easily greppable way is on my wishlist.

    Especially because I see the MSDN docs are rolling out new "Did you want to generate a sample of this? Here's a prompt you can copy paste into Copilot to generate an example: xxxxxxx blah blah"

  • sky2224 1 day ago
    The biggest thing to be aware of honestly is the difference between .NET Framework and .NET Core.

    Essentially, .NET Core has dropped the "Core" moniker. It's just .NET (I tend to refer to it as .NET proper when differentiating between Framework). This change began with .NET 5.0.

    If you're starting from scratch, you will want to build everything using .NET now. Do not use .NET Framework unless absolutely necessary. Probably the most common reason you'd be stuck using .NET Framework is because your project is reliant on some driver or library that isn't making the transition to .NET proper. If you're in this situation, you should try to move as much stuff as you can to be on .NET proper and then use .NET Standard, a middle man library Microsoft developed for this exact situation, to allow for cohesion between .NET Framework and .NET proper.

    Otherwise, in terms of specific "modern" coding practices? I'd say to pay attention to modern OOP approaches in general. Dependency Injection seems to be used everywhere now. Also, be careful using Reflection. People get a lot done with it really fast, but if it starts being used for more than just attribute inspection and you're doing some crazy shit with it, that's usually a sign of a bigger architectural issue.

    Lastly, review LINQ if it's been a while for you. Specifically, understand deferred execution as a lot of people shoot themselves in the foot by tacking on a `.ToList()` and enumerating over a massive collection they shouldn't be enumerating over.

    C# has changed a lot, but it's more subtle than the way a lot of other languages have progressed. Mostly just new features that you can survive very easily without. C# 14 is bringing some interesting changes though, but that's still pretty new, so I'd see the release notes on that if you're interested.

  • Xeago 2 days ago
    Echo'ing similar interest with a similar scenario; but would also be much interested in other forms of media, such as screencasts or demo projects with an accompanying show-case document.

    Reading the release notes of the sdk and/or the MSDN pages used to be a great resource, and probably still is, but it's difficult to find new gems.

    • nodra 2 days ago
      Good to know at least someone wants this. I had this as a goal in the new year to start something but just for myself cause it's what I want.
  • dlahoda 2 days ago
  • neonsunset 2 days ago
    Not books but it's really important, in my opinion, to go through official documentation

    https://learn.microsoft.com/en-us/dotnet/core/whats-new/

    https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/

    Can also recommend reading:

    https://learn.microsoft.com/en-us/dotnet/core/tools/ (CLI, it's good)

    https://learn.microsoft.com/en-us/aspnet/core/fundamentals/m...

    https://typescript-is-like-csharp.chrlschn.dev/pages/interme...

    > are there books specifically about using .NET Core on Linux

    There is nothing particular to using ".NET on Linux" - it just works. Standard Linux caveats not specific to .NET apply.