mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-01-03 14:49:59 +01:00
Add item for page 270
This commit is contained in:
parent
a2dd970228
commit
b8a902a536
|
|
@ -4,6 +4,6 @@ If you find any mistakes in the seventh edition, *C# 11 and .NET 7 - Modern Cros
|
|||
|
||||
[**Errata** (35 items)](errata.md): Typos, tool user interface changes, or mistakes in code that would cause a compilation error that prevents a successful build.
|
||||
|
||||
[**Improvements** (23 items)](improvements.md): Changes to text or code that would improve the content. These are optional.
|
||||
[**Improvements** (24 items)](improvements.md): Changes to text or code that would improve the content. These are optional.
|
||||
|
||||
All errata and improvements will be included in the 8th edition planned for publishing in November 2023. To be included they must be submitted by mid-September 2023.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
**Improvements** (23 items)
|
||||
**Improvements** (24 items)
|
||||
|
||||
If you have suggestions for improvements, then please [raise an issue in this repository](https://github.com/markjprice/cs11dotnet7/issues) or email me at markjprice (at) gmail.com.
|
||||
|
||||
|
|
@ -13,6 +13,7 @@ If you have suggestions for improvements, then please [raise an issue in this re
|
|||
- [Page 237 - Implementing functionality using methods](#page-237---implementing-functionality-using-methods)
|
||||
- [Page 241 - Defining flight passengers](#page-241---defining-flight-passengers)
|
||||
- [Page 251 - Setting up a class library and console application](#page-251---setting-up-a-class-library-and-console-application)
|
||||
- [Page 270 - Equality of types](#page-270---equality-of-types)
|
||||
- [Page 299 - Treating warnings as errors](#page-299---treating-warnings-as-errors)
|
||||
- [Page 343 - Packaging a library for NuGet](#page-343---packaging-a-library-for-nuget)
|
||||
- [Page 444 - Connecting to a database](#page-444---connecting-to-a-database)
|
||||
|
|
@ -262,6 +263,33 @@ message saying that required assets are missing, click Yes to add them.
|
|||
Harry was born on a Sunday.
|
||||
```
|
||||
|
||||
# Page 270 - Equality of types
|
||||
|
||||
> Thanks to [Masoud Nazari](https://github.com/MAS-OUD) for raising this [issue on 17 March 2023](https://github.com/markjprice/cs11dotnet7/issues/44).
|
||||
|
||||
In Step 1, I tell the reader to write a statement to output the values of two integers and if they are equal, as shown in the following code:
|
||||
```cs
|
||||
WriteLine($"a == b: {(a == b)}");
|
||||
```
|
||||
It is not necessary to wrap the equality expression in parentheses like this: `(a == b)`. In more complex expressions it might be necessary to control to order of a calculation, and some developers prefer adding parentheses, but here it is not needed, and some code editors like Visual Studio 2022 will recommend that they are removed.
|
||||
|
||||
In the next edition, I will remove the parentheses, as shown in the following code:
|
||||
```cs
|
||||
WriteLine($"a == b: {a == b}");
|
||||
```
|
||||
|
||||
I will do the same for the output statements in Steps 3, 5, and 7, as shown in the following code:
|
||||
```cs
|
||||
// Step 3 statement will become:
|
||||
WriteLine($"p1 == p2: {p1 == p2}");
|
||||
|
||||
// Step 5 statement will become:
|
||||
WriteLine($"p1 == p3: {p1 == p3}");
|
||||
|
||||
// Step 7 statement will become:
|
||||
WriteLine($"p1.Name == p2.Name: {p1.Name == p2.Name}");
|
||||
```
|
||||
|
||||
# Page 299 - Treating warnings as errors
|
||||
|
||||
This section shows how to follow best practice and treat warnings as errors. But doing so means you must write extra code in common scenarios to fix all warnings that will now be treated as errors that prevent compilation during the build process.
|
||||
|
|
|
|||
Loading…
Reference in a new issue