C# 10 and .NET 6 – Modern Cross-Platform Development
eBook - ePub

C# 10 and .NET 6 – Modern Cross-Platform Development

Mark J. Price

Partager le livre
  1. 824 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

C# 10 and .NET 6 – Modern Cross-Platform Development

Mark J. Price

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

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.

]]>

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que C# 10 and .NET 6 – Modern Cross-Platform Development est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  C# 10 and .NET 6 – Modern Cross-Platform Development par Mark J. Price en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Programming in C#. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2021
ISBN
9781801076968

06

Implementing Interfaces and Inheriting Classes

This chapter is about deriving new types from existing ones using object-oriented programming (OOP). You will learn about defining operators and local functions for performing simple actions and delegates and events for exchanging messages between types. You will implement interfaces for common functionality. You will learn about generics and the difference between reference and value types. You will create a derived class to inherit from a base class to reuse functionality, override an inherited type member, and use polymorphism. Finally, you will learn how to create extension methods and how to cast between classes in an inheritance hierarchy.
This chapter covers the following topics:
  • 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

Setting up a class library and console application

We will start by defining a workspace/solution with two projects like the one created in Chapter 5, Building Your Own Types with Object-Oriented Programming. Even if you completed all the exercises in that chapter, follow the instructions below because we will use C# 10 features in the class library, so it needs to target .NET 6.0 rather than .NET Standard 2.0:
  1. Use your preferred coding tool to create a new workspace/solution named Chapter06.
  2. Add a class library project, as defined in the following list:
    1. Project template: Class Library / classlib
    2. Workspace/solution file and folder: Chapter06
    3. Project file and folder: PacktLibrary
  3. Add a console app project, as defined in the following list:
    1. Project template: Console Application / console
    2. Workspace/solution file and folder: Chapter06
    3. Project file and folder: PeopleApp
  4. In the PacktLibrary project, rename the file named Class1.cs to Person.cs.
  5. Modify the Person.cs file contents, as shown in the following code:
    using static System.Console; namespace Packt.Shared; public class Person : object { // fields public string? Name; // ? allows null public DateTime DateOfBirth; public List<Person> Children = new(); // C# 9 or later // methods public void WriteToConsole() { WriteLine($"{Name} was born on a {DateOfBirth:dddd}."); } } 
  6. In the PeopleApp project, add a project reference to PacktLibrary, as shown highlighted in the following markup:
    <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net6.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup>  <ItemGroup>  <ProjectReference  Include="..\PacktLibrary\PacktLibrary.csproj" />  </ItemGroup> </Project> 
  7. Build the PeopleApp project and note the output indicating that both projects have been built successfully.

More about methods

We might want two instances of Person to be able to procreate. We can implement this by writing methods. Instance methods are actions that an object does to itself; static methods are actions the type does.
Which you choose depends on what makes the most sense for the action.
Go...

Table des matiĂšres