mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-02-26 08:54:13 +01:00
Added issue for page 244
This commit is contained in:
parent
1fe883005b
commit
29764067b8
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
If you find any mistakes in the seventh edition, *C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals*, or 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.
|
||||
|
||||
[**Errata** (47 items)](errata.md): Typos, tool user interface changes, or mistakes in code that would cause a compilation error that prevents a successful build.
|
||||
[**Errata** (48 items)](errata.md): Typos, tool user interface changes, or mistakes in code that would cause a compilation error that prevents a successful build.
|
||||
|
||||
[**Improvements** (44 items)](improvements.md): Changes to text or code that would improve the content. These are optional.
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ If you find any mistakes, then please [raise an issue in this repository](https:
|
|||
- [Page 188 - Running unit tests using Visual Studio Code](#page-188---running-unit-tests-using-visual-studio-code)
|
||||
- [Page 231 - Requiring properties to be set during instantiation](#page-231---requiring-properties-to-be-set-during-instantiation)
|
||||
- [Page 235 - More about methods](#page-235---more-about-methods)
|
||||
- [Page 244 - Enhancements to pattern matching in C# 9 or later](#page-244---enhancements-to-pattern-matching-in-c-9-or-later)
|
||||
- [Page 244 - Init-only properties](#page-244---init-only-properties)
|
||||
- [Page 256 - Defining and handling delegates](#page-256---defining-and-handling-delegates)
|
||||
- [Page 258 - Defining and handling events](#page-258---defining-and-handling-events)
|
||||
|
|
@ -382,6 +383,25 @@ In this section, we define some methods and operators so that two `Person` objec
|
|||
|
||||
cgwid suggested a solution in [the issue they raised](https://github.com/markjprice/cs11dotnet7/issues/59). I want to rethink this code example for the next edition to avoid it becoming overly complex so I will leave it to the reader to decide how they might want to solve it. Meanwhile, I have added an improvement with suggested alternative code here: https://github.com/markjprice/cs11dotnet7/blob/main/docs/errata/improvements.md#page-235---more-about-methods
|
||||
|
||||
# Page 244 - Enhancements to pattern matching in C# 9 or later
|
||||
|
||||
> Thanks to [Noel Arzola Jr](https://github.com/NoelArzola) for raising this [issue on 22 October 2023](https://github.com/markjprice/cs11dotnet7/issues/87).
|
||||
|
||||
At the end of this section, I wrote, "You could also use the relational pattern in combination with the property pattern to avoid the nested
|
||||
switch expression, as shown in the following code:"
|
||||
```cs
|
||||
FirstClassPassenger { AirMiles: > 35000 } => 1500,
|
||||
FirstClassPassenger { AirMiles: > 15000 } => 1750M,
|
||||
FirstClassPassenger => 2000M,"
|
||||
```
|
||||
|
||||
The `1500` return value is missing the decimal suffix `M`. The code should be:
|
||||
```cs
|
||||
FirstClassPassenger { AirMiles: > 35000 } => 1500M,
|
||||
FirstClassPassenger { AirMiles: > 15000 } => 1750M,
|
||||
FirstClassPassenger => 2000M,"
|
||||
```
|
||||
|
||||
# Page 244 - Init-only properties
|
||||
|
||||
> Thanks to Bob Molloy for raising this issue via email.
|
||||
|
|
|
|||
Loading…
Reference in a new issue