Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals - Eighth Edition
C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals - Eighth Edition

C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals: Start building websites and services with ASP.NET Core 8, Blazor, and EF Core 8, Eighth Edition

eBook
AU$55.99 AU$38.99
Print
AU$68.99
Subscription
AU$19.99 Monthly

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

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

C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals, Eighth Edition: Start building websites and services with ASP.NET Core 8, Blazor, and EF Core 8

Welcome to Packt Early Access. We’re giving you an exclusive preview of this book before it goes on sale. It can take many months to write a book, but our authors have cutting-edge information to share with you today. Early Access gives you an insight into the latest developments by making chapter drafts available. The chapters may be a little rough around the edges right now, but our authors will update them over time.You can dip in and out of this book or follow along from start to finish; Early Access is designed to be flexible. We hope you enjoy getting to know more about the process of writing a Packt book.

  1. Chapter 1: Hello, C#! Welcome, .NET!
  2. Chapter 2: Speaking C#
  3. Chapter 3: Controlling Flow, Converting Types, and Handling Exceptions
  4. Chapter 4: Writing, Debugging, and Testing...

Introducing this book and its contents

Let’s get started by introducing you to the code solutions and structure of this book.

Getting code solutions for this book

The GitHub repository for this book has solutions using full application projects for all code tasks and exercises, found at the following link:

https://github.com/markjprice/cs12dotnet8

After navigating to the GitHub repository in your web browser, press the . (dot) key on your keyboard, or manually change .com to .dev in the link to convert the repository into a live code editor based on Visual Studio Code using GitHub Codespaces, as shown in Figure 1.1:

Figure 1.1: GitHub Codespaces live editing the book’s GitHub repository

We provide you with a PDF file that has color images of the screenshots and diagrams used in this book. You can download this file from https://packt.link/gbp/9781837635870.

Visual Studio Code in a web browser is great to run alongside your...

Setting up your development environment

Before you start programming, you’ll need a code editor for C#. Microsoft has a family of code editors and Integrated Development Environments (IDEs), which include:

  • Visual Studio 2022 for Windows
  • Visual Studio Code for Windows, Mac, or Linux
  • Visual Studio Code for the Web or GitHub Codespaces

Third parties have created their own C# code editors, for example, JetBrains Rider, which is available for Windows, Mac, or Linux but does have a license cost. JetBrains Rider is popular with more experienced .NET developers.

Warning! Although JetBrains is a fantastic company with great products, both Rider and the ReSharper extension for Visual Studio are software, and all software has bugs and quirky behavior. For example, they might show errors like “Cannot resolve symbol” in your Razor Pages, Razor views, and Blazor components. Yet you can build and run those files because there is no...

Understanding .NET

“Those who cannot remember the past are condemned to repeat it.”

– George Santayana

.NET, .NET Core, .NET Framework, and Xamarin are related and overlapping platforms for developers used to build applications and services.

If you are not familiar with the history of .NET, then I introduce you to each of these .NET concepts at the following link:

https://github.com/markjprice/cs12dotnet8/blob/main/docs/ch01-dotnet-history.md

Understanding .NET support

.NET versions are either Long Term Support (LTS), Standard Term Support (STS) (formerly known as Current), or Preview, as described in the following list:

  • LTS releases are a good choice for applications that you do not intend to update frequently, although you must update the .NET runtime for your production code monthly. LTS releases are supported by Microsoft for 3 years after General Availability (GA), or 1 year after the next LTS release ships...

Building console apps using Visual Studio 2022

The goal of this section is to showcase how to build a console app using Visual Studio 2022 for Windows.

If you do not have a Windows computer or want to use Visual Studio Code, then you can skip this section since the code will be the same; just the tooling experience is different. But I recommend that you review this section because it does explain some of the code and how top-level programs work, and that information applies to all code editors.

This section is also available in the GitHub repository (so it can be updated after publishing if needed) at the following link:

https://github.com/markjprice/cs12dotnet8/blob/main/docs/code-editors/vs4win.md

If you want to see similar instructions for using JetBrains Rider, they are available in the GitHub repository at the following link:

https://github.com/markjprice/cs12dotnet8/blob/main/docs/code-editors/rider.md

Writing code using Visual Studio 2022

Let’...

Building console apps using Visual Studio Code

The goal of this section is to showcase how to build a console app using Visual Studio Code and the dotnet CLI.

If you never want to try Visual Studio Code or the dotnet command-line tool, then please feel free to skip this section, and then continue with the Making good use of the GitHub repository for this book section.

Both the instructions and screenshots in this section are for Windows, but the same actions will work with Visual Studio Code on the macOS and Linux variants.

The main differences will be native command-line actions such as deleting a file: both the command and the path are likely to be different on Windows or macOS and Linux. Luckily, the dotnet CLI tool itself and its commands are identical on all platforms.

Writing code using Visual Studio Code

Let’s get started writing code!

  1. Start your favorite tool for working with the filesystem, for example, File Explorer on Windows or Finder...

Making good use of the GitHub repository for this book

Git is a commonly used source code management system. GitHub is a company, website, and desktop application that makes it easier to manage Git. Microsoft purchased GitHub in 2018, so it will continue to get closer integration with Microsoft tools.

I created a GitHub repository for this book, and I use it for the following:

  • To store the solution code for the book that can be maintained after the print publication date.
  • To provide extra materials that extend the book, like errata fixes, small improvements, lists of useful links, and optional sections about topics that cannot fit in the printed book.
  • To provide a place for readers to get in touch with me if they have issues with the book.

Good Practice: I strongly recommend that all readers review the errata, improvements, post-publication changes, and common errors pages before attempting any coding task in this book. You can find them...

Looking for help

This section is all about how to find quality information about programming on the web.

Reading the documentation on Microsoft Learn

The definitive resource for getting help with Microsoft developer tools and platforms is in the technical documentation on Microsoft Learn, and you can find it at the following link: https://learn.microsoft.com/en-us/docs.

Documentation links in this book

The official Microsoft documentation for .NET needs to cover all versions. The default version shown in the documentation is always the most recent GA version.

For example, between November 2023 and November 2024, the default version of .NET shown in documentation pages will be 8.0. Between November 2024 and November 2025, the default version of .NET will be 9.0. The following link will automatically direct to the current version depending on the current date:

https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.stringsyntaxattribute

...

Practicing and exploring

Let’s now test your knowledge and understanding by trying to answer some questions, getting some hands-on practice, and going into the topics covered throughout this chapter in greater detail.

Exercise 1.1 – Test your knowledge

Try to answer the following questions, remembering that although most answers can be found in this chapter, you should do some online research or code writing to answer others:

  1. Is Visual Studio 2022 better than Visual Studio Code?
  2. Are .NET 5 and later better than .NET Framework?
  3. What is .NET Standard and why is it still important?
  4. Why can a programmer use different languages, for example, C# and F#, to write applications that run on .NET?
  5. What is a top-level program and how do you access any command-line arguments?
  6. What is the name of the entry point method of a .NET console app and how should it be explicitly declared if you are not using the top-level program feature?
  7. ...

Summary

In this chapter, we:

  • Set up your development environment.
  • Discussed the similarities and differences between modern .NET, .NET Core, .NET Framework, Xamarin, and .NET Standard in an online article.
  • Used Visual Studio 2022 and Visual Studio Code with the .NET SDK CLI to create a couple of simple console apps grouped in a solution.
  • Learned how to download the solution code for this book from its GitHub repository.
  • Learned how to find help. This could be in the traditional way, by using help command switches, documentation, and articles, or the modern way, by having a conversation with a coding expert AI, or using an AI-based tool to perform “grunt work.”

In the next chapter, you will learn how to “speak” C#.

Learn more on Discord

To join the Discord community for this book – where you can share feedback, ask questions to the author, and learn about new releases – follow the QR code below:

https://packt.link/csharp12dotnet8

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • 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

Description

This latest edition of the bestselling Packt series will give you a solid foundation to start building projects using modern C# and .NET with confidence. You'll learn about 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 fi lesystem, 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. You'll handle errors robustly through the 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 reduce memory use and run faster. 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 web development flexibility.

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, 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

Product Details

Country selected

Publication date : Nov 14, 2023
Length 828 pages
Edition : 8th Edition
Language : English
ISBN-13 : 9781837635870
Category :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details


Publication date : Nov 14, 2023
Length 828 pages
Edition : 8th Edition
Language : English
ISBN-13 : 9781837635870
Category :

Table of Contents

18 Chapters
Preface Chevron down icon Chevron up icon
1. Hello, C#! Welcome, .NET! Chevron down icon Chevron up icon
2. Speaking C# Chevron down icon Chevron up icon
3. Controlling Flow, Converting Types, and Handling Exceptions Chevron down icon Chevron up icon
4. Writing, Debugging, and Testing Functions Chevron down icon Chevron up icon
5. Building Your Own Types with Object-Oriented Programming Chevron down icon Chevron up icon
6. Implementing Interfaces and Inheriting Classes Chevron down icon Chevron up icon
7. Packaging and Distributing .NET Types Chevron down icon Chevron up icon
8. Working with Common .NET Types Chevron down icon Chevron up icon
9. Working with Files, Streams, and Serialization Chevron down icon Chevron up icon
10. Working with Data Using Entity Framework Core Chevron down icon Chevron up icon
11. Querying and Manipulating Data Using LINQ Chevron down icon Chevron up icon
12. Introducing Web Development Using ASP.NET Core Chevron down icon Chevron up icon
13. Building Websites Using ASP.NET Core Razor Pages Chevron down icon Chevron up icon
14. Building and Consuming Web Services Chevron down icon Chevron up icon
15. Building User Interfaces Using Blazor Chevron down icon Chevron up icon
16. Epilogue Chevron down icon Chevron up icon
17. Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(10 Ratings)
5 star 70%
4 star 20%
3 star 0%
2 star 10%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by


Michael Börner Feb 20, 2024
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Feefo Verified review Feefo image
Thomas Jäger Feb 6, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Ich programmiere bereits über 10 Jahre mit .Net und C# und konnte immer noch Neues entdecken und bestehende Skills erweitern!
Feefo Verified review Feefo image
N/A Jan 25, 2024
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Feefo Verified review Feefo image
N/A Jan 25, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Feefo Verified review Feefo image
N/A Jan 21, 2024
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
it needs to elaborate more on the subjects I didn't see any fundamentals and not even whats the new on the Net 8 framework , is missing better code examples , the mayority of developers we look a resource to prepare for interviews and there's so little we can take from this book
Feefo Verified review Feefo image
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.