ProfessionalCSharp2021 icon indicating copy to clipboard operation
ProfessionalCSharp2021 copied to clipboard

Source code for Professional C# and .NET 2021 Edition (with updates for C# 11 and .NET 7)

Professional C# and .NET - 2021 Edition

Code samples for the Wrox Press book Professional C# and .NET - 2021 Edition

To compile and run the samples, you need Visual Studio 2019, Visual Studio for Mac, or Visual Studio Code.

You can download these tools here: Visual Studio.

The console app samples can be used on Windows, Linux, or Mac. Here is the installation procedure for .NET: .NET

If you're using Visual Studio, Version 16.9 or a later version of Visual Studio 2019 is needed. With the Visual Studio Installer you need to select this workload to compile most of the code samples: .NET Core cross-platform development. For working with .NET 6, you should use Visual Studio 2022.

ASP.NET Core samples need this workload: ASP.NET and web development.

See the WinUI.md for the requirements of building and running the WinUI samples.

Updates and .NET 6

See updates for issues in the book and updates. See .NET 6 Updates for changes with .NET 6 and C# 10.

The main branch is the actual working branch with code samples updated to .NET 6 and C# 10. Every code sample should compile and run successfully (with the deadlock and race-conditions samples, successfully means that a deadlock and a race-condition occurs).

The dotnet5 branch is used to show the samples how they appear in the printed book.

Issues and Discussions

If you find some problems with the source code, issues to compile and run the samples, please create an issue.

If you have some questions about the code samples, or just want to drop a message, you're welcome to use Discussions.

For questions with your source code that are not related to the book and the code samples, it's better to use StackOverflow.

Slides

I'm offering training and consulting programming .NET applications and services. For academic use, slides are available for free in a separate private repository. Just send me an email using your university / high school account, tell me how you intent to use the book to get access to the available, and send me your github account. You'll get access to this repository.

If you are interested for commercial use of the presentations, get in contact for a commercial offering.

Source Code

Here's the list of chapters and the folders for the code samples:

Part 1 (The Language)

  • Chapter 1 - .NET Applications and Tools (HelloWorld)
  • Chapter 2 - Core C# (CoreCsharp)
  • Chapter 3 - Classes, Structs, Tuples, and Records (Types)
  • Chapter 4 - Object-Oriented Programming with C# (ObjectOrientation)
  • Chapter 5 - Operators and Casts (OperatorsAndCasts)
  • Chapter 6 - Arrays (Arrays)
  • Chapter 7 - Delegates, Lambdas, and Events (Delegates)
  • Chapter 8 - Collections (Collections)
  • Chapter 9 - Language Integrated Query (LINQ)
  • Chapter 10 - Errors and Exceptions (ErrorsAndExceptions)
  • Chapter 11 - Tasks and Asynchronous Programming (Async)
  • Chapter 12 - Reflection, Metadata, and Source Generators (ReflectionAndSourceGenerators)
  • Chapter 13 - Managed and Umanaged Memory (Memory)

Part 2 (The Libraries)

  • Chapter 14 - Libraries, Assemblies, Packages, and NuGet (Libraries)
  • Chapter 15 - Dependency Injection and Configuration (DependencyInjectionAndConfiguration)
  • Chapter 16 - Diagnostics and Metrics (LoggingAndMetrics)
  • Chapter 17 - Parallel Programming (Parallel)
  • Chapter 18 - Files and Streams (FilesAndStreams)
  • Chapter 19 - Networking (Networking)
  • Chapter 20 - Security (Security)
  • Chapter 21 - Entity Framework Core (EFCore)
  • Chapter 22 - Localization (Localization)
  • Chapter 23 - Tests (Tests)

Part 3 (Web Apps and Services)

  • Chapter 24 - ASP.NET Core (AspNetCore)
  • Chapter 25 - Services (Services)
  • Chapter 26 - Razor Pages and MVC (RazorAndMVC)
  • Chapter 27 - Blazor (Blazor)
  • Chapter 28 - SignalR (SignalR)

Part 4 (Windows Apps)

  • Chapter 29 - Windows Apps (Windows)
  • Chapter 30 - Patterns with XAML Apps (Patterns)
  • Chapter 31 - Styling Windows Apps (Styles)

Part 5 (More Samples)

Additional articles and samples related to the book

The Language

The Libraries

Web Apps and Services

Windows Apps

  • Custom Behavior
  • XamlUiCommand

Code of conduct

See Code of conduct

Have fun coding and enjoy the book!

Christian