How to escape curly braces in C#

1 Answer

0 votes
using System;
 
class Program
{
    static void Main() {
        string s = "8 - 0 - 2 - 6";
         
        string code = $"Code = {{{s}}}"; 
        Console.WriteLine(code);
         
        string result = $"Result = {{C# - 18}}"; 
        Console.WriteLine(result);
    }
}
 
 
 
 
/*
run:
 
Code = {8 - 0 - 2 - 6}
Result = {C# - 18}
 
*/

 

 



answered Jun 6, 2021 by avibootz
edited Jun 14, 2023 by avibootz

Related questions

1 answer 163 views
1 answer 166 views
166 views asked Feb 7, 2017 by avibootz
1 answer 179 views
1 answer 192 views
1 answer 426 views
...