C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals, Eighth Edition

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

An accessible guide for beginner-to-intermediate programmers to the concepts, real-world applications, and latest features of C# 12 and .NET 8, with hands-on exercises using Visual Studio 2022 and Visual Studio Code. Key Features Explore the latest additions to C# 12, the .NET 8 class libraries, and Entity Framework Core 8 Create professional websites and services with ASP.NET Core 8 and Blazor Build your confidence with step-by-step code examples and tips for best practices Book Description This Packt bestseller will give you a solid foundation to start building apps and services with confidence. You'll learn object-oriented programming, writing, testing, and debugging functions, and implementing interfaces. You'll take on .NET APIs for managing and querying data, working with the filesystem, and serialization. As you progress, you'll explore examples of cross-platform projects you can build and deploy, such as websites and services using ASP.NET Core. This latest edition integrates .NET 8 enhancements into its examples: type aliasing and primary constructors for concise and expressive code, and lambda expressions with parameter defaults for more flexible code. You’ll handle errors robustly through new built-in guard clauses and explore a simplified implementation of caching in ASP.NET Core 8. If that’s not enough, you’ll also see how native ahead-of-time (AOT) compiler publish lets web services reach new heights. You’ll work with the seamless new HTTP Editor in Visual Studio 2022 to enhance the testing and debugging process. You’ll even get introduced to Blazor Full Stack with its new unified hosting model for unparalleled code reusability. What you will learn Discover C# 12's new features, including aliasing any type and primary constructors Try out the native AOT publish capability for ASP.NET Core 8 Minimal APIs web services Build rich web experiences using Blazor Full Stack, Razor Pages, the Model-View-Controller (MVC) pattern, and other ASP.NET Core features Integrate and update databases in your apps using Entity Framework Core models Query and manipulate data using LINQ Build and consume powerful services using Web API and Minimal API Who this book is for This book is for beginners as well as intermediate-level C# and .NET programmers who have worked with C# in the past and want to catch up with the changes made in the last few years. Prior exposure to C# or .NET is not a prerequisite. A general understanding of programming will help you to work through the book more comfortably, though the content is suitable for those completely new to programming. If you already have some C# and .NET skills and want to focus on developing practical apps, you can pick up Mark’s other .NET book, Apps and Services with .NET 8, instead.

Author(s): Mark J. Price
Edition: 8
Publisher: Packt
Year: 2023

Language: English
Pages: 1118

Preface
Where to find the code solutions
What this book covers
What you need for this book
Get in touch
Hello, C#! Welcome, .NET!
Introducing this book and its contents
Setting up your development environment
Understanding .NET
Building console apps using Visual Studio 2022
Building console apps using Visual Studio Code
Making good use of the GitHub repository for this book
Looking for help
Practicing and exploring
Summary
Speaking C#
Introducing the C# language
Discovering your C# compiler version
Understanding C# grammar and vocabulary
Working with variables
Exploring more about console apps
Understanding async and await
Practicing and exploring
Summary
Controlling Flow, Converting Types, and Handling Exceptions
Operating on variables
Understanding iteration statements
Storing multiple values in an array
Casting and converting between types
Handling exceptions
Checking for overflow
Practicing and exploring
Summary
Writing, Debugging, and Testing Functions
Writing functions
Debugging during development
Logging during development and runtime
Unit testing
Throwing and catching exceptions in functions
Practicing and exploring
Summary
Building Your Own Types with Object-Oriented Programming
Talking about OOP
Pattern matching with objects
Working with record types
Practicing and exploring
Summary
Implementing Interfaces and Inheriting Classes
Setting up a class library and console application
Static methods and overloading operators
Making types safely reusable with generics
Raising and handling events
Implementing interfaces
Managing memory with reference and value types
Working with null values
Inheriting from classes
Casting within inheritance hierarchies
Inheriting and extending .NET types
Summarizing custom type choices
Practicing and exploring
Summary
Packaging and Distributing .NET Types
The road to .NET 8
Understanding .NET components
Publishing your code for deployment
Native ahead-of-time compilation
Decompiling .NET assemblies
Packaging your libraries for NuGet distribution
Working with preview features
Practicing and exploring
Summary
Working with Common .NET Types
Working with numbers
Working with text
Pattern matching with regular expressions
Storing multiple objects in collections
Working with spans, indexes, and ranges
Practicing and exploring
Summary
Working with Files, Streams, and Serialization
Managing the filesystem
Reading and writing with streams
Encoding and decoding text
Serializing object graphs
Working with environment variables
Practicing and exploring
Summary
Working with Data Using Entity Framework Core
Understanding modern databases
Setting up EF Core in a .NET project
Defining EF Core models
Querying EF Core models
Loading and tracking patterns with EF Core
Modifying data with EF Core
Practicing and exploring
Summary
Querying and Manipulating Data Using LINQ
Writing LINQ expressions
LINQ in practice
Sorting and more
Using LINQ with EF Core
Joining, grouping, and lookups
Aggregating and paging sequences
Practicing and exploring
Summary
Introducing Web Development Using ASP.NET Core
Understanding ASP.NET Core
Structuring projects
Building an entity model for use in the rest of the book
Understanding web development
Practicing and exploring
Summary
Building Websites Using ASP.NET Core Razor Pages
Exploring ASP.NET Core
Exploring ASP.NET Core Razor Pages
Using Entity Framework Core with ASP.NET Core
Configuring services and the HTTP request pipeline
Practicing and exploring
Summary
Building and Consuming Web Services
Building web services using the ASP.NET Core Web API
Creating a web service for the Northwind database
Documenting and testing web services
Consuming web services using HTTP clients
Practicing and exploring
Summary
Building User Interfaces Using Blazor
History of Blazor
Reviewing the Blazor Web App project template
Building components using Blazor
Enabling client-side execution using WebAssembly
Practicing and exploring
Summary
Epilogue
Next steps on your C# and .NET learning journey
The ninth edition, coming November 2024
Good luck!
Index