Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Chapter02/Listing02.01.SpecifyingLiteralValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static void Main()
System.Console.WriteLine(42);

System.Console.WriteLine(1.618034);
#endregion
#endregion INCLUDE
}
}
}
2 changes: 1 addition & 1 deletion src/Chapter02/Listing02.02.SpecifyingALiteralDouble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static void Main()
{
#region INCLUDE
System.Console.WriteLine(1.6180339887498948);
#endregion
#endregion INCLUDE
}
}
}
2 changes: 1 addition & 1 deletion src/Chapter02/Listing02.03.SpecifyingALiteralDecimal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static void Main()
{
#region INCLUDE
System.Console.WriteLine(1.6180339887498948M);
#endregion
#endregion INCLUDE
}
}
}
2 changes: 1 addition & 1 deletion src/Chapter02/Listing02.04.UsingTheDigitSeparator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static void Main()
{
#region INCLUDE
System.Console.WriteLine(9_814_072_356M);
#endregion
#endregion INCLUDE
}
}
}
2 changes: 1 addition & 1 deletion src/Chapter02/Listing02.05.ExponentialNotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static void Main()
{
#region INCLUDE
System.Console.WriteLine(6.023E23F);
#endregion
#endregion INCLUDE
}
}
}
2 changes: 1 addition & 1 deletion src/Chapter02/Listing02.06.HexadecimalLiteralValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static void Main()
#region INCLUDE
//Display the value 42 using a hexadecimal literal
System.Console.WriteLine(0x002A);
#endregion
#endregion INCLUDE
}
}
}
2 changes: 1 addition & 1 deletion src/Chapter02/Listing02.07.BinaryLiteralValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static void Main()
#region INCLUDE
// Display the value 42 using a binary literal
System.Console.WriteLine(0b101010);
#endregion
#endregion INCLUDE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static void Main()
#region INCLUDE
//Displays "0x2A"
System.Console.WriteLine($"0x{42:X}");
#endregion
#endregion INCLUDE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void Main()
System.Console.WriteLine($"{result == number}: {result} == {number}");

// ...
#endregion
#endregion INCLUDE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static void Main()
string option = "help";

int comparison = string.Compare(option, "/Help", true);
#endregion
#endregion INCLUDE

System.Console.WriteLine($"{comparison}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public static void Main()
System.Console.WriteLine('\'');
}
}
#endregion
#endregion INCLUDE
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static void Main()
System.Console.Write('\u003A');

System.Console.WriteLine('\u0029');
#endregion
#endregion INCLUDE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public static void Main()
System.Console.Write("\n\"Wait 'til I get going!\"\n");
}
}
#endregion
#endregion INCLUDE
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public static void Main()
end");
}
}
#endregion
#endregion INCLUDE
}
12 changes: 6 additions & 6 deletions src/Chapter02/Listing02.15.UsingStaticDirectives.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_15
// The using directives allow you to drop the namespace
#region HIGHLIGHT
using static System.Console;
#endregion
#endregion HIGHLIGHT
public class HeyYou
{
public static void Main()
Expand All @@ -14,23 +14,23 @@ public static void Main()

#region HIGHLIGHT
WriteLine("Hey you!");
#endregion
#endregion HIGHLIGHT

#region HIGHLIGHT
Write("Enter your first name: ");
firstName = ReadLine();
#endregion
#endregion HIGHLIGHT

Write("Enter your last name: ");
#region HIGHLIGHT
lastName = ReadLine();
#endregion
#endregion HIGHLIGHT

#region HIGHLIGHT
WriteLine(
#endregion
#endregion HIGHLIGHT
$"Your full name is {firstName} {lastName}.");
}
}
#endregion
#endregion INCLUDE
}
4 changes: 2 additions & 2 deletions src/Chapter02/Listing02.16.UsingStringsLengthMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public static void Main()
$"The palindrome \"{palindrome}\" is"
#region HIGHLIGHT
+ $" {palindrome.Length} characters.");
#endregion
#endregion HIGHLIGHT
}
}
#endregion
#endregion INCLUDE
}
4 changes: 2 additions & 2 deletions src/Chapter02/Listing02.17.Error-StringIsImmutable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public static void Main()
#region HIGHLIGHT
// UNEXPECTED: Does not convert text to uppercase
text.ToUpper();
#endregion
#endregion HIGHLIGHT

System.Console.WriteLine(text);
}
}
#endregion
#endregion INCLUDE
}
4 changes: 2 additions & 2 deletions src/Chapter02/Listing02.18.WorkingWithStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public static void Main()
// Return a new string in uppercase
#region HIGHLIGHT
uppercase = text.ToUpper();
#endregion
#endregion HIGHLIGHT

System.Console.WriteLine(uppercase);
}
}
#endregion
#endregion INCLUDE
}
4 changes: 2 additions & 2 deletions src/Chapter02/Listing02.19.AssigningNullToAString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public static void Main()

#region EXCLUDE
System.Console.WriteLine($"The age is: {age}");
#endregion
#endregion EXCLUDE
}
#endregion
#endregion INCLUDE
}
}
2 changes: 1 addition & 1 deletion src/Chapter02/Listing02.20.ExplicitCastExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static void Main()
#region INCLUDE
long longNumber = 50918309109;
int intNumber = (int)longNumber;
#endregion
#endregion INCLUDE
}
}
}
2 changes: 1 addition & 1 deletion src/Chapter02/Listing02.21.OverflowingAnIntegerValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public static void Main()
System.Console.WriteLine(n);
}
}
#endregion
#endregion INCLUDE
}
6 changes: 3 additions & 3 deletions src/Chapter02/Listing02.22.ACheckedBlockExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ public static void Main()
#region HIGHLIGHT
checked
{
#endregion
#endregion HIGHLIGHT
// int.MaxValue equals 2147483647
int n = int.MaxValue;
n = n + 1;
System.Console.WriteLine(n);
#region HIGHLIGHT
}
#endregion
#endregion HIGHLIGHT
}
}
#endregion
#endregion INCLUDE
}
2 changes: 1 addition & 1 deletion src/Chapter02/Listing02.23.AnUncheckedBlockExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public static void Main()
}
}
}
#endregion
#endregion INCLUDE
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static void Main()
#region INCLUDE
int intNumber = 31416;
long longNumber = intNumber;
#endregion
#endregion INCLUDE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static void Main()
#region INCLUDE
int intNumber = 31416;
long longNumber = (long)intNumber;
#endregion
#endregion INCLUDE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static void Main()
#region INCLUDE
string text = "9.11E-31";
float kgElectronMass = float.Parse(text);
#endregion
#endregion INCLUDE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static void Main()
string middleCText = "261.626";
double middleC = System.Convert.ToDouble(middleCText);
bool boolean = System.Convert.ToBoolean(middleC);
#endregion
#endregion INCLUDE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static void Main()
string text = boolean.ToString();
// Display "True"
System.Console.WriteLine(text);
#endregion
#endregion INCLUDE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public static void Main()
// ...
}
else
#endregion
#endregion HIGHLIGHT
{
System.Console.WriteLine(
"The text entered was not a valid number.");
}
#endregion
#endregion INCLUDE
}
}
}
4 changes: 2 additions & 2 deletions src/Chapter02/Listing02.30.UsingTryParseWithInlineOut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void Main()
System.Console.WriteLine(
#region HIGHLIGHT
$"input was parsed successfully to {number}.");
#endregion
#endregion HIGHLIGHT
}
else
{
Expand All @@ -26,7 +26,7 @@ public static void Main()

System.Console.WriteLine(
$"'number' currently has the value: {number}");
#endregion
#endregion INCLUDE
}
}
}