diff --git a/src/Chapter02.Tests/Listing02.14.Tests.cs b/src/Chapter02.Tests/Listing02.14.Tests.cs index b6430dcd1..feb9c9522 100644 --- a/src/Chapter02.Tests/Listing02.14.Tests.cs +++ b/src/Chapter02.Tests/Listing02.14.Tests.cs @@ -14,7 +14,7 @@ public void Main_WriteTriangle() / \ / \ /________\ -end"; + end"; IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, Triangle.Main); diff --git a/src/Chapter02/Listing02.01.SpecifyingLiteralValues.cs b/src/Chapter02/Listing02.01.SpecifyingLiteralValues.cs index 88ff2c640..becdfdc0b 100644 --- a/src/Chapter02/Listing02.01.SpecifyingLiteralValues.cs +++ b/src/Chapter02/Listing02.01.SpecifyingLiteralValues.cs @@ -4,8 +4,11 @@ public class Program { public static void Main() { + #region INCLUDE System.Console.WriteLine(42); + System.Console.WriteLine(1.618034); + #endregion } } } diff --git a/src/Chapter02/Listing02.02.SpecifyingALiteralDouble.cs b/src/Chapter02/Listing02.02.SpecifyingALiteralDouble.cs index 99dc2f08a..a8e785c1b 100644 --- a/src/Chapter02/Listing02.02.SpecifyingALiteralDouble.cs +++ b/src/Chapter02/Listing02.02.SpecifyingALiteralDouble.cs @@ -4,7 +4,9 @@ public class Program { public static void Main() { + #region INCLUDE System.Console.WriteLine(1.6180339887498948); + #endregion } } } diff --git a/src/Chapter02/Listing02.03.SpecifyingALiteralDecimal.cs b/src/Chapter02/Listing02.03.SpecifyingALiteralDecimal.cs index d51b73f54..50b572ec3 100644 --- a/src/Chapter02/Listing02.03.SpecifyingALiteralDecimal.cs +++ b/src/Chapter02/Listing02.03.SpecifyingALiteralDecimal.cs @@ -4,7 +4,9 @@ public class Program { public static void Main() { + #region INCLUDE System.Console.WriteLine(1.6180339887498948M); + #endregion } } } diff --git a/src/Chapter02/Listing02.04.UsingTheDigitSeparator.cs b/src/Chapter02/Listing02.04.UsingTheDigitSeparator.cs index ba9edf753..f9cfed21a 100644 --- a/src/Chapter02/Listing02.04.UsingTheDigitSeparator.cs +++ b/src/Chapter02/Listing02.04.UsingTheDigitSeparator.cs @@ -4,7 +4,9 @@ public class Program { public static void Main() { + #region INCLUDE System.Console.WriteLine(9_814_072_356M); + #endregion } } } diff --git a/src/Chapter02/Listing02.05.ExponentialNotation.cs b/src/Chapter02/Listing02.05.ExponentialNotation.cs index 844d68d2b..a5477c679 100644 --- a/src/Chapter02/Listing02.05.ExponentialNotation.cs +++ b/src/Chapter02/Listing02.05.ExponentialNotation.cs @@ -4,7 +4,9 @@ public class Program { public static void Main() { + #region INCLUDE System.Console.WriteLine(6.023E23F); + #endregion } } } diff --git a/src/Chapter02/Listing02.06.HexadecimalLiteralValue.cs b/src/Chapter02/Listing02.06.HexadecimalLiteralValue.cs index 71485684f..2ba456464 100644 --- a/src/Chapter02/Listing02.06.HexadecimalLiteralValue.cs +++ b/src/Chapter02/Listing02.06.HexadecimalLiteralValue.cs @@ -4,8 +4,10 @@ public class Program { public static void Main() { + #region INCLUDE //Display the value 42 using a hexadecimal literal System.Console.WriteLine(0x002A); + #endregion } } } diff --git a/src/Chapter02/Listing02.07.BinaryLiteralValue.cs b/src/Chapter02/Listing02.07.BinaryLiteralValue.cs index 4de815aa6..b7adae2e6 100644 --- a/src/Chapter02/Listing02.07.BinaryLiteralValue.cs +++ b/src/Chapter02/Listing02.07.BinaryLiteralValue.cs @@ -4,8 +4,10 @@ public class Program { public static void Main() { + #region INCLUDE // Display the value 42 using a binary literal System.Console.WriteLine(0b101010); + #endregion } } } diff --git a/src/Chapter02/Listing02.08.ExamplesOfAHexadecimalFormatSpecifier.cs b/src/Chapter02/Listing02.08.ExamplesOfAHexadecimalFormatSpecifier.cs index 3a58d769d..02ed22910 100644 --- a/src/Chapter02/Listing02.08.ExamplesOfAHexadecimalFormatSpecifier.cs +++ b/src/Chapter02/Listing02.08.ExamplesOfAHexadecimalFormatSpecifier.cs @@ -4,8 +4,10 @@ public class Program { public static void Main() { + #region INCLUDE //Displays "0x2A" System.Console.WriteLine($"0x{42:X}"); + #endregion } } } diff --git a/src/Chapter02/Listing02.09.FormattingUsingTheRFormatSpecifier.cs b/src/Chapter02/Listing02.09.FormattingUsingTheRFormatSpecifier.cs index 14867537c..624aefd7f 100644 --- a/src/Chapter02/Listing02.09.FormattingUsingTheRFormatSpecifier.cs +++ b/src/Chapter02/Listing02.09.FormattingUsingTheRFormatSpecifier.cs @@ -4,6 +4,8 @@ public class Program { public static void Main() { + #region INCLUDE + // ... const double number = 1.618033988749895; double result; string text; @@ -15,6 +17,9 @@ public static void Main() text = string.Format("{0:R}", number); result = double.Parse(text); System.Console.WriteLine($"{result == number}: {result} == {number}"); + + // ... + #endregion } } } diff --git a/src/Chapter02/Listing02.10.CaseInsensitiveComparisonOfTwoStrings.cs b/src/Chapter02/Listing02.10.CaseInsensitiveComparisonOfTwoStrings.cs index 447b3a637..6019f1cc9 100644 --- a/src/Chapter02/Listing02.10.CaseInsensitiveComparisonOfTwoStrings.cs +++ b/src/Chapter02/Listing02.10.CaseInsensitiveComparisonOfTwoStrings.cs @@ -4,9 +4,11 @@ public class Program { public static void Main() { + #region INCLUDE string option = "help"; int comparison = string.Compare(option, "/Help", true); + #endregion System.Console.WriteLine($"{comparison}"); } diff --git a/src/Chapter02/Listing02.11.DisplayingASingleQuoteUsingAnEscapeSequence.cs b/src/Chapter02/Listing02.11.DisplayingASingleQuoteUsingAnEscapeSequence.cs index 2e05516c0..b2f4a0a59 100644 --- a/src/Chapter02/Listing02.11.DisplayingASingleQuoteUsingAnEscapeSequence.cs +++ b/src/Chapter02/Listing02.11.DisplayingASingleQuoteUsingAnEscapeSequence.cs @@ -1,5 +1,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_11 { + #region INCLUDE public class SingleQuote { public static void Main() @@ -7,4 +8,5 @@ public static void Main() System.Console.WriteLine('\''); } } + #endregion } diff --git a/src/Chapter02/Listing02.12.UsingUnicodeEncodingToDisplayASmileyFace.cs b/src/Chapter02/Listing02.12.UsingUnicodeEncodingToDisplayASmileyFace.cs index 0396b6a3a..00a67031d 100644 --- a/src/Chapter02/Listing02.12.UsingUnicodeEncodingToDisplayASmileyFace.cs +++ b/src/Chapter02/Listing02.12.UsingUnicodeEncodingToDisplayASmileyFace.cs @@ -4,8 +4,11 @@ public class SingleQuote { public static void Main() { + #region INCLUDE System.Console.Write('\u003A'); + System.Console.WriteLine('\u0029'); + #endregion } } } diff --git a/src/Chapter02/Listing02.13.UsingTheNewlineCharacterToInsertANewline.cs b/src/Chapter02/Listing02.13.UsingTheNewlineCharacterToInsertANewline.cs index 11837d66d..9fb633d1a 100644 --- a/src/Chapter02/Listing02.13.UsingTheNewlineCharacterToInsertANewline.cs +++ b/src/Chapter02/Listing02.13.UsingTheNewlineCharacterToInsertANewline.cs @@ -1,5 +1,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_13 { + #region INCLUDE public class DuelOfWits { public static void Main() @@ -9,4 +10,5 @@ public static void Main() System.Console.Write("\n\"Wait 'til I get going!\"\n"); } } + #endregion } diff --git a/src/Chapter02/Listing02.14.DisplayingATriangleUsingAVerbatimStringLiteral.cs b/src/Chapter02/Listing02.14.DisplayingATriangleUsingAVerbatimStringLiteral.cs index c26207383..96db58a25 100644 --- a/src/Chapter02/Listing02.14.DisplayingATriangleUsingAVerbatimStringLiteral.cs +++ b/src/Chapter02/Listing02.14.DisplayingATriangleUsingAVerbatimStringLiteral.cs @@ -1,5 +1,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_14 { + #region INCLUDE public class Triangle { public static void Main() @@ -10,7 +11,8 @@ public static void Main() / \ / \ /________\ -end"); + end"); } } + #endregion } diff --git a/src/Chapter02/Listing02.15.UsingStaticDirectives.cs b/src/Chapter02/Listing02.15.UsingStaticDirectives.cs index 64554ab32..50ba615e5 100644 --- a/src/Chapter02/Listing02.15.UsingStaticDirectives.cs +++ b/src/Chapter02/Listing02.15.UsingStaticDirectives.cs @@ -1,6 +1,10 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_15 -{ +{ + #region INCLUDE + // The using directives allow you to drop the namespace + #region HIGHLIGHT using static System.Console; + #endregion public class HeyYou { public static void Main() @@ -8,16 +12,25 @@ public static void Main() string firstName; string lastName; + #region HIGHLIGHT WriteLine("Hey you!"); + #endregion + #region HIGHLIGHT Write("Enter your first name: "); firstName = ReadLine(); + #endregion Write("Enter your last name: "); + #region HIGHLIGHT lastName = ReadLine(); + #endregion + #region HIGHLIGHT WriteLine( + #endregion $"Your full name is {firstName} {lastName}."); } } + #endregion } diff --git a/src/Chapter02/Listing02.16.UsingStringsLengthMember.cs b/src/Chapter02/Listing02.16.UsingStringsLengthMember.cs index e9d28b120..c23d8ed27 100644 --- a/src/Chapter02/Listing02.16.UsingStringsLengthMember.cs +++ b/src/Chapter02/Listing02.16.UsingStringsLengthMember.cs @@ -1,5 +1,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_16 { + #region INCLUDE public class PalindromeLength { public static void Main() @@ -11,7 +12,10 @@ public static void Main() System.Console.WriteLine( $"The palindrome \"{palindrome}\" is" + #region HIGHLIGHT + $" {palindrome.Length} characters."); + #endregion } } + #endregion } diff --git a/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs b/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs index a24e647e6..e417be9f6 100644 --- a/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs +++ b/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs @@ -1,5 +1,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_17 { + #region INCLUDE public class Uppercase { public static void Main() @@ -9,10 +10,13 @@ public static void Main() System.Console.Write("Enter text: "); text = System.Console.ReadLine(); + #region HIGHLIGHT // UNEXPECTED: Does not convert text to uppercase text.ToUpper(); + #endregion System.Console.WriteLine(text); } } + #endregion } \ No newline at end of file diff --git a/src/Chapter02/Listing02.18.WorkingWithStrings.cs b/src/Chapter02/Listing02.18.WorkingWithStrings.cs index 508543987..0ea855d8b 100644 --- a/src/Chapter02/Listing02.18.WorkingWithStrings.cs +++ b/src/Chapter02/Listing02.18.WorkingWithStrings.cs @@ -1,5 +1,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_18 { + #region INCLUDE public class Uppercase { public static void Main() @@ -10,9 +11,12 @@ public static void Main() text = System.Console.ReadLine(); // Return a new string in uppercase + #region HIGHLIGHT uppercase = text.ToUpper(); + #endregion System.Console.WriteLine(uppercase); } } + #endregion } diff --git a/src/Chapter02/Listing02.19.AssigningNullToAString.cs b/src/Chapter02/Listing02.19.AssigningNullToAString.cs index 39926f38c..fe8ea9a76 100644 --- a/src/Chapter02/Listing02.19.AssigningNullToAString.cs +++ b/src/Chapter02/Listing02.19.AssigningNullToAString.cs @@ -2,18 +2,19 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_19 { public class Program { + #region INCLUDE public static void Main() { int? age; - //... // Clear the value of age age = null; - //... - - System.Console.WriteLine($"The age is: {age}"); + #region EXCLUDE + System.Console.WriteLine($"The age is: {age}"); + #endregion } + #endregion } } diff --git a/src/Chapter02/Listing02.20.ExplicitCastExample.cs b/src/Chapter02/Listing02.20.ExplicitCastExample.cs index 5fc25911c..d9cf01aad 100644 --- a/src/Chapter02/Listing02.20.ExplicitCastExample.cs +++ b/src/Chapter02/Listing02.20.ExplicitCastExample.cs @@ -4,8 +4,10 @@ public class Program { public static void Main() { + #region INCLUDE long longNumber = 50918309109; int intNumber = (int)longNumber; + #endregion } } } diff --git a/src/Chapter02/Listing02.21.OverflowingAnIntegerValue.cs b/src/Chapter02/Listing02.21.OverflowingAnIntegerValue.cs index 2a0e0b47d..a75e57492 100644 --- a/src/Chapter02/Listing02.21.OverflowingAnIntegerValue.cs +++ b/src/Chapter02/Listing02.21.OverflowingAnIntegerValue.cs @@ -1,5 +1,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_21 { + #region INCLUDE public class Program { public static void Main() @@ -10,4 +11,5 @@ public static void Main() System.Console.WriteLine(n); } } + #endregion } diff --git a/src/Chapter02/Listing02.22.ACheckedBlockExample.cs b/src/Chapter02/Listing02.22.ACheckedBlockExample.cs index e86f3be16..738e69bd9 100644 --- a/src/Chapter02/Listing02.22.ACheckedBlockExample.cs +++ b/src/Chapter02/Listing02.22.ACheckedBlockExample.cs @@ -1,16 +1,22 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_22 { + #region INCLUDE public class Program { public static void Main() { + #region HIGHLIGHT checked { + #endregion // int.MaxValue equals 2147483647 int n = int.MaxValue; n = n + 1; System.Console.WriteLine(n); + #region HIGHLIGHT } + #endregion } } + #endregion } diff --git a/src/Chapter02/Listing02.23.AnUncheckedBlockExample.cs b/src/Chapter02/Listing02.23.AnUncheckedBlockExample.cs index 4d629d5bc..fd6f16833 100644 --- a/src/Chapter02/Listing02.23.AnUncheckedBlockExample.cs +++ b/src/Chapter02/Listing02.23.AnUncheckedBlockExample.cs @@ -1,5 +1,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_23 { + #region INCLUDE public class Program { public static void Main() @@ -13,4 +14,5 @@ public static void Main() } } } + #endregion } diff --git a/src/Chapter02/Listing02.24.NotUsingTheCastOperatorForAnImplicitCast.cs b/src/Chapter02/Listing02.24.NotUsingTheCastOperatorForAnImplicitCast.cs index 47f611507..eff43b733 100644 --- a/src/Chapter02/Listing02.24.NotUsingTheCastOperatorForAnImplicitCast.cs +++ b/src/Chapter02/Listing02.24.NotUsingTheCastOperatorForAnImplicitCast.cs @@ -4,8 +4,10 @@ public class Program { public static void Main() { + #region INCLUDE int intNumber = 31416; long longNumber = intNumber; + #endregion } } } diff --git a/src/Chapter02/Listing02.25.UsingTheCastOperatorForAnImplicitCast.cs b/src/Chapter02/Listing02.25.UsingTheCastOperatorForAnImplicitCast.cs index 7cea8090b..0d769eed7 100644 --- a/src/Chapter02/Listing02.25.UsingTheCastOperatorForAnImplicitCast.cs +++ b/src/Chapter02/Listing02.25.UsingTheCastOperatorForAnImplicitCast.cs @@ -4,8 +4,10 @@ public class Program { public static void Main() { + #region INCLUDE int intNumber = 31416; long longNumber = (long)intNumber; + #endregion } } } diff --git a/src/Chapter02/Listing02.26.UsingIntParseToConvertAStringToANumericDataType.cs b/src/Chapter02/Listing02.26.UsingIntParseToConvertAStringToANumericDataType.cs index f8f2ed79e..19f9ce787 100644 --- a/src/Chapter02/Listing02.26.UsingIntParseToConvertAStringToANumericDataType.cs +++ b/src/Chapter02/Listing02.26.UsingIntParseToConvertAStringToANumericDataType.cs @@ -4,8 +4,10 @@ public class Program { public static void Main() { + #region INCLUDE string text = "9.11E-31"; float kgElectronMass = float.Parse(text); + #endregion } } } diff --git a/src/Chapter02/Listing02.27.TypeConversionUsingSystemConvert.cs b/src/Chapter02/Listing02.27.TypeConversionUsingSystemConvert.cs index 852fff248..47effe719 100644 --- a/src/Chapter02/Listing02.27.TypeConversionUsingSystemConvert.cs +++ b/src/Chapter02/Listing02.27.TypeConversionUsingSystemConvert.cs @@ -4,9 +4,11 @@ public class Program { public static void Main() { + #region INCLUDE string middleCText = "261.626"; double middleC = System.Convert.ToDouble(middleCText); bool boolean = System.Convert.ToBoolean(middleC); + #endregion } } } diff --git a/src/Chapter02/Listing02.28.UsingToStringToConvertToAString.cs b/src/Chapter02/Listing02.28.UsingToStringToConvertToAString.cs index 08b8e55df..1ab70e1a7 100644 --- a/src/Chapter02/Listing02.28.UsingToStringToConvertToAString.cs +++ b/src/Chapter02/Listing02.28.UsingToStringToConvertToAString.cs @@ -4,10 +4,12 @@ public class Program { public static void Main() { + #region INCLUDE bool boolean = true; string text = boolean.ToString(); // Display "True" System.Console.WriteLine(text); + #endregion } } } diff --git a/src/Chapter02/Listing02.29.UsingTryParseInPlaceOfAnInvalidCastException.cs b/src/Chapter02/Listing02.29.UsingTryParseInPlaceOfAnInvalidCastException.cs index 131793930..8bc84582a 100644 --- a/src/Chapter02/Listing02.29.UsingTryParseInPlaceOfAnInvalidCastException.cs +++ b/src/Chapter02/Listing02.29.UsingTryParseInPlaceOfAnInvalidCastException.cs @@ -6,23 +6,25 @@ public class Program { public static void Main() { + #region INCLUDE double number; -#pragma warning restore IDE0018 // Inline variable declaration string input; System.Console.Write("Enter a number: "); input = System.Console.ReadLine(); - - if(double.TryParse(input, out number)) + #region HIGHLIGHT + if (double.TryParse(input, out number)) { // Converted correctly, now use number // ... } else + #endregion { System.Console.WriteLine( "The text entered was not a valid number."); } + #endregion } } } diff --git a/src/Chapter02/Listing02.30.UsingTryParseWithInlineOut.cs b/src/Chapter02/Listing02.30.UsingTryParseWithInlineOut.cs index 119101327..5ad19d456 100644 --- a/src/Chapter02/Listing02.30.UsingTryParseWithInlineOut.cs +++ b/src/Chapter02/Listing02.30.UsingTryParseWithInlineOut.cs @@ -4,6 +4,7 @@ public class Program { public static void Main() { + #region INCLUDE // double number; string input; @@ -12,7 +13,9 @@ public static void Main() if (double.TryParse(input, out double number)) { System.Console.WriteLine( + #region HIGHLIGHT $"input was parsed successfully to {number}."); + #endregion } else { @@ -23,6 +26,7 @@ public static void Main() System.Console.WriteLine( $"'number' currently has the value: {number}"); + #endregion } } }