From 9e1cff95ed1d8e37681c65868a20d60552cf7395 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Fri, 29 Nov 2024 13:10:49 +0100 Subject: [PATCH] more fun with strings --- .../EssentialCsharp/Program.cs | 88 ++++++++++++------- 1 file changed, 56 insertions(+), 32 deletions(-) diff --git a/Emne 3/EssentialCsharp/EssentialCsharp/Program.cs b/Emne 3/EssentialCsharp/EssentialCsharp/Program.cs index 2a0a665..e66816a 100644 --- a/Emne 3/EssentialCsharp/EssentialCsharp/Program.cs +++ b/Emne 3/EssentialCsharp/EssentialCsharp/Program.cs @@ -2,16 +2,16 @@ { public class Program { - public static void Main(string[] args) - { - bool ignoreCase = true; - string option = "/help"; - - int comparison = string.Compare(option, "/Help", ignoreCase); - bool isHelpREquested = (comparison == 0); - Console.WriteLine($"Help Requested: {isHelpREquested}"); - Console.WriteLine("\u0029"); - Console.WriteLine(@" + public static void Main(string[] args) + { + bool ignoreCase = true; + string option = "/help"; + + int comparison = string.Compare(option, "/Help", ignoreCase); + bool isHelpREquested = (comparison == 0); + Console.WriteLine($"Help Requested: {isHelpREquested}"); + Console.WriteLine("\u0029"); + Console.WriteLine(@" , , /( )` @@ -34,7 +34,8 @@ `--{__________) \/ "); - Console.WriteLine(@" + Console.WriteLine( + @" @@ -75,26 +76,49 @@ ███ "); - string name = "mobius"; - Console.Write( - $$""" - Begin - ____ - / /\ - / / \ - / / /\ - / / / \ - / / /\ \ - / / / \ \ - / / /\ \ \ - / / / \ \ \ - /___/___/____\ \ \ - / {{{name}}} \ \ \ - /________________\ \ \ - \ \ \ / - \_________________\___\/ - End - """); - } + string name = "mobius"; + Console.Write( + $$""" + Begin + ____ + / /\ + / / \ + / / /\ + / / / \ + / / /\ \ + / / / \ \ + / / /\ \ \ + / / / \ \ \ + /___/___/____\ \ \ + / {{{name}}} \ \ \ + /________________\ \ \ + \ \ \ / + \_________________\___\/ + End + """); + string mamaSaid = // Multi-line raw string literal. + """ + Mama said, "Life was just a box of chocolates..." + """; + string jsonDialogue = $$""" + { + "quote": { + "character": "The MAN", + "dialogue": "" + }, + "description": "She nods, not much interested. He...", + "quote": { + "character": "The MAN", + "dialogue": "" + }, + "description": "She shakes \"no\" He unwraps it...", + "quote": { + "character": "The MAN", + "dialogue": "{{mamaSaid.Replace("\"", "\\\"")}}" + } + } + """; + Console.WriteLine(jsonDialogue); + } } } \ No newline at end of file