Book description
Publisher’s Note: Microsoft will stop supporting .NET 6 from November 2024. The newer 8th edition of the book is available that covers .NET 8 (end-of-life November 2026) with C# 12 and EF Core 8. Purchase of the print or Kindle book includes a free PDF eBook
Key Features
- Explore the newest additions to C# 10, the .NET 6 class library, and Entity Framework Core 6
- Create professional websites and services with ASP.NET Core 6 and Blazor
- Build cross-platform apps for Windows, macOS, Linux, iOS, and Android
Book Description
Extensively revised to accommodate all the latest features that come with C# 10 and .NET 6, this latest edition of our comprehensive guide will get you coding in C# with confidence.
You’ll learn object-oriented programming, writing, testing, and debugging functions, implementing interfaces, and inheriting classes. The book covers the .NET APIs for performing tasks like managing and querying data, monitoring and improving performance, and working with the filesystem, async streams, and serialization. You’ll build and deploy cross-platform apps, such as websites and services using ASP.NET Core.
Instead of distracting you with unnecessary application code, the first twelve chapters will teach you about C# language constructs and many of the .NET libraries through simple console applications. In later chapters, having mastered the basics, you’ll then build practical applications and services using ASP.NET Core, the Model-View-Controller (MVC) pattern, and Blazor.
What you will learn
- Build rich web experiences using Blazor, Razor Pages, the Model-View-Controller (MVC) pattern, and other features of ASP.NET Core
- Build your own types with object-oriented programming
- Write, test, and debug functions
- Query and manipulate data using LINQ
- Integrate and update databases in your apps using Entity Framework Core, Microsoft SQL Server, and SQLite
- Build and consume powerful services using the latest technologies, including gRPC and GraphQL
- Build cross-platform apps using XAML
Who this book is for
Designed for both beginners and C# and .NET programmers who have worked with C# in the past and want to catch up with the changes made in the past few years, this book doesn’t need you to have any C# or .NET experience. However, you should have a general understanding of programming before you jump in.
Table of contents
- Preface
-
Hello, C#! Welcome, .NET!
- Setting up your development environment
-
Understanding .NET
- Understanding .NET Framework
- Understanding the Mono, Xamarin, and Unity projects
- Understanding .NET Core
- Understanding the journey to one .NET
- Understanding .NET support
- What is different about modern .NET?
- Themes of modern .NET
- Understanding .NET Standard
- .NET platforms and tools used by the book editions
- Understanding intermediate language
- Comparing .NET technologies
- Building console apps using Visual Studio 2022
- Building console apps using Visual Studio Code
- Exploring code using .NET Interactive Notebooks
- Reviewing the folders and files for projects
- Making good use of the GitHub repository for this book
- Looking for help
- Practicing and exploring
- Summary
-
Speaking C#
- Introducing the C# language
-
Understanding C# grammar and vocabulary
- Showing the compiler version
- Understanding C# grammar
- Statements
- Comments
- Blocks
- Examples of statements and blocks
- Understanding C# vocabulary
- Comparing programming languages to human languages
- Changing the color scheme for C# syntax
- Help for writing correct code
- Importing namespaces
- Verbs are methods
- Nouns are types, variables, fields, and properties
- Revealing the extent of the C# vocabulary
- Working with variables
- Exploring more about console applications
- Practicing and exploring
- Summary
-
Controlling Flow, Converting Types, and Handling Exceptions
- Operating on variables
- Understanding selection statements
- Understanding iteration statements
- Casting and converting between types
- Handling exceptions
- Checking for overflow
- Practicing and exploring
- Summary
- Writing, Debugging, and Testing Functions
-
Building Your Own Types with Object-Oriented Programming
- Talking about OOP
- Building class libraries
- Storing data within fields
- Storing multiple values using collections
- Writing and calling methods
- Controlling access with properties and indexers
- Pattern matching with objects
- Working with records
- Practicing and exploring
- Summary
-
Implementing Interfaces and Inheriting Classes
- Setting up a class library and console application
- More about methods
- Raising and handling events
- Making types safely reusable with generics
- 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
- Using an analyzer to write better code
- Practicing and exploring
- Summary
-
Packaging and Distributing .NET Types
- The road to .NET 6
-
Understanding .NET components
- Understanding assemblies, NuGet packages, and namespaces
- Understanding the Microsoft .NET project SDKs
- Understanding namespaces and types in assemblies
- Understanding NuGet packages
- Understanding frameworks
- Importing a namespace to use a type
- Relating C# keywords to .NET types
- Sharing code with legacy platforms using .NET Standard
- Understanding defaults for class libraries with different SDKs
- Creating a .NET Standard 2.0 class library
- Controlling the .NET SDK
- Publishing your code for deployment
- Decompiling .NET assemblies
- Packaging your libraries for NuGet distribution
- Porting from .NET Framework to modern .NET
- Working with preview features
- Practicing and exploring
- Summary
-
Working with Common .NET Types
- Working with numbers
- Working with text
- Working with dates and times
- Pattern matching with regular expressions
-
Storing multiple objects in collections
- Common features of all collections
- Improving performance by ensuring the capacity of a collection
- Understanding collection choices
- Working with lists
- Working with dictionaries
- Working with queues
- Sorting collections
- More specialized collections
- Using immutable collections
- Good practice with collections
- Working with spans, indexes, and ranges
- Working with network resources
- Working with reflection and attributes
- Working with images
- Internationalizing your code
- 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
- Controlling JSON processing
- Practicing and exploring
- Summary
-
Working with Data Using Entity Framework Core
-
Understanding modern databases
- Understanding legacy Entity Framework
- Understanding Entity Framework Core
- Creating a console app for working with EF Core
- Using a sample relational database
- Using Microsoft SQL Server for Windows
- Creating the Northwind sample database for SQL Server
- Managing the Northwind sample database with Server Explorer
- Using SQLite
- Creating the Northwind sample database for SQLite
- Managing the Northwind sample database with SQLiteStudio
- Setting up EF Core
-
Defining EF Core models
- Using EF Core conventions to define the model
- Using EF Core annotation attributes to define the model
- Using the EF Core Fluent API to define the model
- Building an EF Core model for the Northwind tables
- Adding tables to the Northwind database context class
- Setting up the dotnet-ef tool
- Scaffolding models using an existing database
- Configuring preconvention models
- Querying EF Core models
- Loading patterns with EF Core
- Manipulating data with EF Core
- Working with transactions
- Code First EF Core models
- Practicing and exploring
- Summary
-
Understanding modern databases
-
Querying and Manipulating Data Using LINQ
-
Writing LINQ expressions
- What makes LINQ?
- Building LINQ expressions with the Enumerable class
- Filtering entities with Where
- Targeting a named method
- Simplifying the code by removing the explicit delegate instantiation
- Targeting a lambda expression
- Sorting entities
- Declaring a query using var or a specified type
- Filtering by type
- Working with sets and bags using LINQ
- Using LINQ with EF Core
- Sweetening LINQ syntax with syntactic sugar
- Using multiple threads with parallel LINQ
- Creating your own LINQ extension methods
- Working with LINQ to XML
- Practicing and exploring
- Summary
-
Writing LINQ expressions
- Improving Performance and Scalability Using Multitasking
- Introducing Practical Applications of C# and .NET
-
Building Websites Using ASP.NET Core Razor Pages
- Understanding web development
- Understanding ASP.NET Core
- Exploring ASP.NET Core Razor Pages
- Using Entity Framework Core with ASP.NET Core
- Using Razor class libraries
- Configuring services and the HTTP request pipeline
- Practicing and exploring
- Summary
-
Building Websites Using the Model-View-Controller Pattern
- Setting up an ASP.NET Core MVC website
- Exploring an ASP.NET Core MVC website
- Customizing an ASP.NET Core MVC website
- Querying a database and using display templates
- Improving scalability using asynchronous tasks
-
Practicing and exploring
- Exercise 15.1 – Test your knowledge
- Exercise 15.2 – Practice implementing MVC by implementing a category detail page
- Exercise 15.3 – Practice improving scalability by understanding and implementing async action methods
- Exercise 15.4 – Practice unit testing MVC controllers
- Exercise 15.5 – Explore topics
- Summary
-
Building and Consuming Web Services
-
Building web services using ASP.NET Core Web API
- Understanding web service acronyms
- Understanding HTTP requests and responses for Web APIs
- Creating an ASP.NET Core Web API project
- Reviewing the web service's functionality
- Creating a web service for the Northwind database
- Creating data repositories for entities
- Implementing a Web API controller
- Configuring the customer repository and Web API controller
- Specifying problem details
- Controlling XML serialization
- Documenting and testing web services
- Consuming web services using HTTP clients
- Implementing advanced features for web services
- Building web services using minimal APIs
- Practicing and exploring
- Summary
-
Building web services using ASP.NET Core Web API
-
Building User Interfaces Using Blazor
- Understanding Blazor
- Comparing Blazor project templates
- Building components using Blazor Server
- Abstracting a service for a Blazor component
- Building components using Blazor WebAssembly
- Improving Blazor WebAssembly apps
- Practicing and exploring
- Summary
- Epilogue
- Index
Product information
- Title: C# 10 and .NET 6 – Modern Cross-Platform Development - Sixth Edition
- Author(s):
- Release date: November 2021
- Publisher(s): Packt Publishing
- ISBN: 9781801077361
You might also like
book
C# 11 and .NET 7 – Modern Cross-Platform Development Fundamentals - Seventh Edition
Publisher’s Note: Microsoft will stop supporting .NET 7 from May 2024. The newer 8th edition of …
book
C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals - Eighth Edition
An accessible guide for beginner-to-intermediate programmers to the concepts, real-world applications, and latest features of C# …
book
Software Architecture with C# 10 and .NET 6 - Third Edition
Design scalable and high-performance enterprise applications using the latest features of C# 10 and .NET 6 …
book
C# 9 and .NET 5 – Modern Cross-Platform Development - Fifth Edition
Publisher’s Note: Microsoft stopped supporting .NET 5 in May 2022. The newer 8th edition of the …