From 4a4a0b8e203c066bc14a5fe07e8cb9495d07af81 Mon Sep 17 00:00:00 2001 From: Mark J Price Date: Fri, 8 Jul 2022 16:05:38 +0100 Subject: [PATCH] Initial commit --- vs4win/Chapter08/WorkingWithCollections/Program.cs | 4 ++-- vs4win/Chapter08/WorkingWithRegularExpressions/Program.cs | 8 +++++++- vscode/Chapter08/WorkingWithCollections/Program.cs | 4 ++-- vscode/Chapter08/WorkingWithRegularExpressions/Program.cs | 8 +++++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/vs4win/Chapter08/WorkingWithCollections/Program.cs b/vs4win/Chapter08/WorkingWithCollections/Program.cs index 599e08e..0958d30 100644 --- a/vs4win/Chapter08/WorkingWithCollections/Program.cs +++ b/vs4win/Chapter08/WorkingWithCollections/Program.cs @@ -65,7 +65,7 @@ foreach (KeyValuePair item in keywords) WriteLine($" {item.Key}: {item.Value}"); } -// lookup a value using a key +// look up a value using a key string key = "long"; WriteLine($"The definition of {key} is {keywords[key]}"); @@ -99,7 +99,7 @@ PriorityQueue vaccine = new(); // add some people // 1 = high priority people in their 70s or poor health -// 2 = medium priority e.g. middle aged +// 2 = medium priority e.g. middle-aged // 3 = low priority e.g. teens and twenties vaccine.Enqueue("Pamela", 1); // my mum (70s) diff --git a/vs4win/Chapter08/WorkingWithRegularExpressions/Program.cs b/vs4win/Chapter08/WorkingWithRegularExpressions/Program.cs index 434bbd8..5d4250e 100644 --- a/vs4win/Chapter08/WorkingWithRegularExpressions/Program.cs +++ b/vs4win/Chapter08/WorkingWithRegularExpressions/Program.cs @@ -14,7 +14,13 @@ else WriteLine($"This is not a valid age: {input}"); } -string films = "\"Monsters, Inc.\",\"I, Tonya\",\"Lock, Stock and Two Smoking Barrels\""; +// C# 1 to 10: Use escaped double-quote characters \" +// string films = "\"Monsters, Inc.\",\"I, Tonya\",\"Lock, Stock and Two Smoking Barrels\""; + +// C# 11 or later: Use """ to start and end a raw string literal +string films = """ +"Monsters, Inc.","I, Tonya","Lock, Stock and Two Smoking Barrels" +"""; WriteLine($"Films to split: {films}"); diff --git a/vscode/Chapter08/WorkingWithCollections/Program.cs b/vscode/Chapter08/WorkingWithCollections/Program.cs index 599e08e..0958d30 100644 --- a/vscode/Chapter08/WorkingWithCollections/Program.cs +++ b/vscode/Chapter08/WorkingWithCollections/Program.cs @@ -65,7 +65,7 @@ foreach (KeyValuePair item in keywords) WriteLine($" {item.Key}: {item.Value}"); } -// lookup a value using a key +// look up a value using a key string key = "long"; WriteLine($"The definition of {key} is {keywords[key]}"); @@ -99,7 +99,7 @@ PriorityQueue vaccine = new(); // add some people // 1 = high priority people in their 70s or poor health -// 2 = medium priority e.g. middle aged +// 2 = medium priority e.g. middle-aged // 3 = low priority e.g. teens and twenties vaccine.Enqueue("Pamela", 1); // my mum (70s) diff --git a/vscode/Chapter08/WorkingWithRegularExpressions/Program.cs b/vscode/Chapter08/WorkingWithRegularExpressions/Program.cs index 434bbd8..5d4250e 100644 --- a/vscode/Chapter08/WorkingWithRegularExpressions/Program.cs +++ b/vscode/Chapter08/WorkingWithRegularExpressions/Program.cs @@ -14,7 +14,13 @@ else WriteLine($"This is not a valid age: {input}"); } -string films = "\"Monsters, Inc.\",\"I, Tonya\",\"Lock, Stock and Two Smoking Barrels\""; +// C# 1 to 10: Use escaped double-quote characters \" +// string films = "\"Monsters, Inc.\",\"I, Tonya\",\"Lock, Stock and Two Smoking Barrels\""; + +// C# 11 or later: Use """ to start and end a raw string literal +string films = """ +"Monsters, Inc.","I, Tonya","Lock, Stock and Two Smoking Barrels" +"""; WriteLine($"Films to split: {films}");