Book Image

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

By : Mark J. Price
4.7 (13)
Book Image

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

4.7 (13)
By: Mark J. Price

Overview of this book

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.
Table of Contents (18 chapters)
17
Index

Working with numbers

One of the most common types of data is numbers. The most common types in .NET for working with numbers are shown in Table 8.1:

Namespace Example type(s) Description
System SByte , Int16 , Int32 , Int64 , Int128 Integers; that is, zero, and positive and negative whole numbers.
System Byte , UInt16 , UInt32 , UInt64 , UInt128 Cardinals; that is, zero and positive whole numbers.
System Half , Single , Double Reals; that is, floating-point numbers.
System Decimal Accurate reals; that is, for use in science, engineering, or financial scenarios.
System.Numerics BigInteger , Complex , Quaternion Arbitrarily large integers, complex numbers, and quaternion numbers.
Table 8.1: Common .NET number types

.NET has had the 32-bit float and 64-bit double types since .NET Framework 1.0 was released in 2002. The IEEE 754 specification also defines a 16-bit floating-point standard. Machine learning and other algorithms would benefit from this smaller, lower-precision...