
Professional C# and .NET, 2021 Edition
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
In Professional C# and .NET: 2021 Edition, Microsoft MVP for Visual Studio and Development Technologies and veteran developer, Christian Nagel, delivers a comprehensive tour of the new features and capabilities of C#9 and .NET 5.
Experienced programmers making the transition to C# will benefit from the author's in-depth explorations to create Web- and Windows applications using ASP.NET Core, Blazor, and WinUI using modern application patterns and new features offered by .NET including Microservices deployed to Docker images, GRPC, localization, asynchronous streaming, and much more.
The book also offers:
* Discussions of the extension of .NET to non-Microsoft platforms like OSX and Linux
* Explanations of the newest features in C#9, including support for record types, and enhanced support for tuples, pattern matching, and nullable reference types
* Integrating .NET applications with Microsoft Azure services such as Azure App
* Configuration, Azure Key Vault, Azure Functions, the Azure Active Directory, and others Downloadable code examples from wrox.com and github.com with online updates for C# 10 and .NET 6
Perfect for programmers with a background in C#, Visual Basic, Java, or C/C++, Professional C# and .NET: 2021 Edition will also earn a place in the libraries of software architects seeking an up-to-date and fulsome treatment of the latest C# and .NET releases.
More details
Other editions
Additional editions

Person
Content
Part I: The C# Language
Chapter 1: .Net Applications And Tools 3
Chapter 2: Core C# 24
Chapter 3: Classes, Records, Structs, And Tuples 59
Chapter 4: Object-Oriented Programming In C# 95
Chapter 5: Operators And Casts 119
Chapter 6: Arrays 153
Chapter 7: Delegates, Lambdas, And Events 177
Chapter 8: Collections 193
Chapter 9: Language Integrated Query 226
Chapter 10: Errors And Exceptions 263
Chapter 11: Tasks And Asynchronous Programming 288
Chapter 12: Reflection, Metadata, And Source Generators 307
Chapter 13: Managed And Unmanaged Memory 335
Part II: Libraries
Chapter 14: Libraries, Assemblies, Packages, And Nuget 377
Chapter 15: Dependency Injection And Configuration 392
Chapter 16: Diagnostics And Metrics 419
Chapter 17: Parallel Programming 440
Chapter 18: Files And Streams 485
Chapter 19: Networking 52
Chapter 20: Security 558
Chapter 21: Entity Framework Core 582
Chapter 22: Localization 644
Chapter 23: Tests 668
Part III: Web Applications And Services
Chapter 24: Asp.Net Core 687
Chapter 25: Services 714
Chapter 26: Razor Pages And Mvc 752
Chapter 27: Blazor 779
Chapter 28: Signalr 801
Part IV: Apps
Chapter 29: Windows Apps 819
Chapter 30: Patterns With Xaml Apps 876
Chapter 31: Styling Windows Apps 899
Index 933
INTRODUCTION
EVEN THOUGH .NET was announced in the year 2000, it is not becoming a grandfather technology. Instead, .NET keeps increasing developer traction since it has become open source and is available not only on Windows but also on Linux platforms. .NET can also run within the browser on the client-without the need to install a plugin-by using the WebAssembly standard.
As new enhancements for C# and .NET are coming, a focus lies not only on performance gains but also on ease of use. .NET more and more is a choice for new developers.
C# is also attractive for long-term developers. Every year, Stack Overflow asks developers about the most loved, dreaded, and wanted programming languages and frameworks. For several years, C# has been within the top 10 of the most loved programming languages. ASP.NET Core now holds the top position as the most loved web framework. .NET Core is number one in the most loved other frameworks/libraries/tools category. See for details.https://insights.stackoverflow.com/survey/2020
When you use C# and ASP.NET Core, you can create web applications and services (including microservices) that run on Windows, Linux, and Mac. You can use the Windows Runtime to create native Windows apps using C#, XAML, and .NET. You can create libraries that you share between ASP.NET Core, Windows apps, and .NET MAUI. You can also create traditional Windows Forms and WPF applications.
Most of the samples of this book are built to run on a Windows or Linux system. Exceptions are the Windows app samples that run only on the Windows platform. You can use Visual Studio, Visual Studio Code, or Visual Studio for the Mac as the developer environment; only the Windows app samples require Visual Studio.
THE WORLD OF .NET
.NET has a long history; the first version was released in the year 2002. The new .NET generation with a complete rewrite of .NET (.NET Core 1.0 in the year 2016) is very young. Recently, many features from the old .NET version have been brought to .NET Core to ease the migration experience.
When creating new applications, there is no reason not to move to the new .NET versions. Whether old applications should stay with the old version of .NET or be migrated to the new one depends on the features used, how difficult the migration is, and what advantages you gain after the application is migrated. The best options here need to be considered with an application-by-application analysis.
The new .NET provides easy ways to create Windows and web applications and services. You can create microservices running in Docker containers in a Kubernetes cluster; create web applications; use the new OpenTelemetry standard to analyze distributed traces in a vendor-independent manner; create web applications returning HTML, JavaScript, and CSS; and create web applications returning HTML, JavaScript, and .NET binaries that run in the client's browser in a safe and standard way using WebAssembly. You can create Windows applications in traditional ways using WPF and Windows Forms and make use of modern XAML features and controls that support the fluent design with WinUI and mobile applications with .NET MAUI.
.NET uses modern patterns. Dependency injection is built into core services, such as ASP.NET Core and EF Core, which not only makes unit testing easier but also allows developers to easily enhance and change features from these technologies.
.NET runs on multiple platforms. Besides Windows and macOS, many Linux environments are supported, such as Alpine, CentOS, Debian, Fedora, openSUSE, Red Hat, SLES, and Ubuntu.
.NET is open source () and freely available. You can find meeting notes for the C# compiler (https://github.com/dotnet), the source code for the C# compiler (https://github.com/dotnet/csharplang), the .NET runtime and libraries (https://github.com/dotnet/Roslyn), and ASP.NET Core (https://github.com/dotnet/runtime) with Razor Pages, Blazor, and SignalR.https://github.com/dotnet/aspnetcore
Here's a summary of some of the features of the new .NET:
- .NET is open source.
- .NET uses modern patterns.
- .NET supports development on multiple platforms.
- ASP.NET Core can run on Windows and Linux.
THE WORLD OF C#
When C# was released in the year 2002, it was a language developed for the .NET Framework. C# was designed with ideas from C++, Java, and Pascal. Anders Hejlsberg had come to Microsoft from Borland and brought experience from the language development of Delphi. At Microsoft, Hejlsberg worked on Microsoft's version of Java, named J++, before creating C#.
NOTE Today, Anders Hejlsberg has moved to TypeScript (although he still influences C#), and Mads Torgersen is the project lead for C#. C# improvements are discussed openly at , and you can read C# language proposals and event meeting notes. You can also submit your own proposals for C#.https://github.com/dotnet/csharplang
C# started not only as an object-oriented general-purpose programming language but was a component-based programming language that supported properties, events, attributes (annotations), and building assemblies (binaries including metadata).
Over time, C# was enhanced with generics, Language Integrated Query (LINQ), lambda expressions, dynamic features, and easier asynchronous programming. C# is not an easy programming language because of the many features it offers, but it's continuously evolving with features that are practical to use. With this, C# is more than an object-oriented or component-based language; it also includes ideas of functional programming-things that are of practical use for a general-purpose language developing all kinds of applications.
Nowadays, a new version of C# is released every year. C# 8 added nullable reference types, and C# 9 added records and more. C# 10 is releasing with .NET 6 in 2021 and C# 11 will be released with .NET 7 in 2022. Because of the frequency of changes nowadays, check the GitHub repository for the book (read more in the section "Source Code") for continuous updates.
WHAT'S NEW IN C#
Every year, a new version of C# is released, with many new features available in each version. The latest versions include features such as nullable reference types to reduce exceptions of type NullableReferenceException and instead let the compiler help more; features to increase productivity such as indices and ranges; switch expressions that make the switch statement look old; features for using declarations; and enhancements with pattern matching. Top-level statements allow reducing the number of source code lines with small applications and records-classes where the compiler creates boilerplate code for equality comparison, deconstruction, and with expressions. Code generators allow creating code automatically while the compiler runs. All these new features are covered in this book.
WHAT'S NEW IN ASP.NET CORE
ASP.NET Core now contains new technology for creating web applications: Blazor Server and Blazor WebAssembly. With Blazor, you have a full-stack option to write C# code both for the client and for the server. With Blazor Server, the Razor components you create containing HTML and C# code run on the server. With Blazor WebAssembly, Razor components written with C# and HTML run on the client using the HTML 5 standard WebAssembly that allows you to run binary code in the browser, which is supported by all modern web browsers.
For creating services, you can now use gRPC with ASP.NET Core for binary communication between services. This is a great option for service-to-service communication to reduce the bandwidth needed, as well as CPU and memory usage if a lot of data transfer is needed.
WHAT'S NEW WITH WINDOWS
For developing applications for Windows, a new technology combines the features of the Universal Windows Platform and desktop applications: WinUI 3. WinUI is the native UI platform for Windows 10 applications. With WinUI 3, you can use modern XAML code that includes compiled binding to create desktop applications. New controls with Microsoft's fluent design system are available. These controls are not delivered with the Windows Runtime as was previously the case with the Universal Windows Platform (UWP). These controls are developed independently of the Windows 10 version that allows you to use the newest controls with Windows 10 versions 1809 and above. As the roadmap available with WinUI shows, these new controls will be usable from WPF applications as well.
WHAT YOU NEED TO WRITE AND RUN C# CODE
.NET runs on Windows, Linux, and Mac operating systems. You can create and build your programs on any of these operating systems using Visual Studio Code (). You can build and run most of the samples on Windows or Linux and use the .NET development tools of your choice. Only the WinUI applications require you to use the Windows platform, and here, Visual Studio is the best option to use. The minimum version required to build and run the WinUI application is version 16.10.https://code.visualstudio.com
The command line plays an important part when using the .NET CLI and the Azure CLI; you can use the new Windows Terminal. With the newest Windows 10 versions, this...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.