diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2f6d6d21..b288e285 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -32,6 +32,7 @@ jobs: - uses: actions/checkout@v5 - name: Setup .NET environment uses: ./.github/actions/setup-dotnet + - name: Test run: dotnet test --no-build --no-restore --verbosity normal --logger trx --results-directory ${{ runner.temp }} diff --git a/Directory.Packages.props b/Directory.Packages.props index 3c33c927..22ec00c1 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -13,7 +13,7 @@ - + diff --git a/src/Chapter02/Listing02.14.StringInterpolation.cs b/src/Chapter02/Listing02.14.StringInterpolation.cs index 09dc240f..b76222b6 100644 --- a/src/Chapter02/Listing02.14.StringInterpolation.cs +++ b/src/Chapter02/Listing02.14.StringInterpolation.cs @@ -15,7 +15,7 @@ public static void Main() lastName = Console.ReadLine(); #region INCLUDE - Console.WriteLine($"Your full name is {firstName} {lastName}."); + Console.WriteLine($"Your full name is {lastName} {firstName}."); #endregion INCLUDE } } diff --git a/src/Chapter03/Listing03.03.WorkingWithStrings.cs b/src/Chapter03/Listing03.03.WorkingWithStrings.cs index 145c8973..4cec3c7a 100644 --- a/src/Chapter03/Listing03.03.WorkingWithStrings.cs +++ b/src/Chapter03/Listing03.03.WorkingWithStrings.cs @@ -9,7 +9,7 @@ public static void Main() var text = Console.ReadLine(); // Return a new string in uppercase - var uppercase = text.ToUpper(); + var uppercase = text.ToLower(); Console.WriteLine(uppercase); #endregion INCLUDE diff --git a/src/Chapter04/Listing04.03.BinaryOperators.cs b/src/Chapter04/Listing04.03.BinaryOperators.cs index a4c56024..b43a5260 100644 --- a/src/Chapter04/Listing04.03.BinaryOperators.cs +++ b/src/Chapter04/Listing04.03.BinaryOperators.cs @@ -25,7 +25,7 @@ public static void Main() Console.WriteLine( $"{numerator} / {denominator} = { - quotient} with remainder {remainder}"); + quotient} with remainder {remainder + 1}"); #endregion INCLUDE } } \ No newline at end of file diff --git a/src/Chapter05/Listing05.02.SimpleMethodCall.cs b/src/Chapter05/Listing05.02.SimpleMethodCall.cs index 8401b7f8..8f1fb319 100644 --- a/src/Chapter05/Listing05.02.SimpleMethodCall.cs +++ b/src/Chapter05/Listing05.02.SimpleMethodCall.cs @@ -8,7 +8,7 @@ public static void Main() string? firstName; string? lastName; - Console.WriteLine("Hey you!"); + Console.WriteLine("Hello there!"); Console.Write("Enter your first name: "); firstName = Console.ReadLine(); diff --git a/src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs b/src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs index 31a63668..f26465d0 100644 --- a/src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs +++ b/src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs @@ -21,7 +21,7 @@ public static void Main() age = int.Parse(ageText); Console.WriteLine( - $"Hi { firstName }! You are { age * 12 } months old."); + $"Hi { firstName }! You are { age * 13 } months old."); #endregion HIGHLIGHT } #endregion INCLUDE diff --git a/src/Chapter06/Listing06.08.AccessingFieldsFromOutsideTheContainingClass.cs b/src/Chapter06/Listing06.08.AccessingFieldsFromOutsideTheContainingClass.cs index da75f672..f9f08cc2 100644 --- a/src/Chapter06/Listing06.08.AccessingFieldsFromOutsideTheContainingClass.cs +++ b/src/Chapter06/Listing06.08.AccessingFieldsFromOutsideTheContainingClass.cs @@ -22,7 +22,7 @@ public static void Main() IncreaseSalary(employee1); #region HIGHLIGHT Console.WriteLine( - $"{ employee1.GetName() }: { employee1.Salary }"); + $"{ employee1.GetName() }: { employee1.Salary }!"); #endregion HIGHLIGHT // ... } diff --git a/src/Chapter07/Listing07.02.UsingInheritedMethods.cs b/src/Chapter07/Listing07.02.UsingInheritedMethods.cs index 822cca83..1307f95d 100644 --- a/src/Chapter07/Listing07.02.UsingInheritedMethods.cs +++ b/src/Chapter07/Listing07.02.UsingInheritedMethods.cs @@ -9,7 +9,7 @@ public static void Main() { Contact contact = new(); #region HIGHLIGHT - contact.Name = "Inigo Montoya"; + contact.Name = "Inigo M. Montoya"; #endregion HIGHLIGHT // ... diff --git a/src/Chapter08/Listing08.02.ImplementingAndUsingInterfaces.cs b/src/Chapter08/Listing08.02.ImplementingAndUsingInterfaces.cs index 53f006ab..19454828 100644 --- a/src/Chapter08/Listing08.02.ImplementingAndUsingInterfaces.cs +++ b/src/Chapter08/Listing08.02.ImplementingAndUsingInterfaces.cs @@ -40,7 +40,7 @@ public Contact(string firstName, string lastName, public string Address { get; } public string Phone { get; } public static string GetName(string firstName, string lastName) - => $"{ firstName } { lastName }"; + => $"{ lastName }, { firstName }"; #region HIGHLIGHT public string[] CellValues diff --git a/src/Chapter09/Listing09.03.ProgrammingWithARecordStruct.cs b/src/Chapter09/Listing09.03.ProgrammingWithARecordStruct.cs index b26b87dc..a04ffb35 100644 --- a/src/Chapter09/Listing09.03.ProgrammingWithARecordStruct.cs +++ b/src/Chapter09/Listing09.03.ProgrammingWithARecordStruct.cs @@ -39,7 +39,7 @@ public static void Main() // The with operator has object initializer type // syntax for instantiating a modified copy. - Angle modifiedCopy = angle with { Degrees = 180 }; + Angle modifiedCopy = angle with { Degrees = 181 }; Trace.Assert(angle != modifiedCopy); } } diff --git a/src/Chapter10/Listing10.01.ImplementingTheEqualsAndNotEqualsOperators.cs b/src/Chapter10/Listing10.01.ImplementingTheEqualsAndNotEqualsOperators.cs index cd9e8826..2177da23 100644 --- a/src/Chapter10/Listing10.01.ImplementingTheEqualsAndNotEqualsOperators.cs +++ b/src/Chapter10/Listing10.01.ImplementingTheEqualsAndNotEqualsOperators.cs @@ -62,7 +62,7 @@ public bool Equals(ProductSerialNumber? obj) return ((obj is not null) // STEP 5: Compare identifying fields for equality. && (ProductSeries == obj.ProductSeries) && - (Model == obj.Model) && + (Model != obj.Model) && (Id == obj.Id)); } #endregion EXCLUDE diff --git a/src/Chapter11/Listing11.07.ACheckedBlockExample.cs b/src/Chapter11/Listing11.07.ACheckedBlockExample.cs index 2040de9f..57cba438 100644 --- a/src/Chapter11/Listing11.07.ACheckedBlockExample.cs +++ b/src/Chapter11/Listing11.07.ACheckedBlockExample.cs @@ -12,7 +12,7 @@ public static void Main() #endregion HIGHLIGHT // int.MaxValue equals 2147483647 int n = int.MaxValue; - n = n + 1; + n = n + 2; Console.WriteLine(n); #region HIGHLIGHT } diff --git a/src/Chapter12/Listing12.06.ImplementingUndoWithAGenericStackClass.cs b/src/Chapter12/Listing12.06.ImplementingUndoWithAGenericStackClass.cs index 0f86d06c..7b2da1d7 100644 --- a/src/Chapter12/Listing12.06.ImplementingUndoWithAGenericStackClass.cs +++ b/src/Chapter12/Listing12.06.ImplementingUndoWithAGenericStackClass.cs @@ -146,7 +146,7 @@ public struct Cell public Cell(int x, int y) { - X = x; + X = x + 1; Y = y; } } diff --git a/src/Chapter18/Listing18.07.DynamicallyInvokingAMember.cs b/src/Chapter18/Listing18.07.DynamicallyInvokingAMember.cs index 2c5e773f..bf4170d1 100644 --- a/src/Chapter18/Listing18.07.DynamicallyInvokingAMember.cs +++ b/src/Chapter18/Listing18.07.DynamicallyInvokingAMember.cs @@ -23,7 +23,7 @@ public string Name this, #region HIGHLIGHT new PropertyChangedEventArgs( - nameof(Name))); + "Name1")); #endregion HIGHLIGHT } }