How to escape curly braces in String.format C#

How to escape curly braces in String.format C#

In this post we will give you information about How to escape curly braces in String.format C#. Hear we will give you detail about How to escape curly braces in String.format C#And how to use it also give you demo for it if it is necessary.

To escape curly braces and interpolate a string inside the String.format() method use triple curly braces {{{ }}}.

Here is an example:

using System;class EscapeDemo {  static void Main() {      string val = "1, 2, 3";      string output =String.Format(" My values are {{{0}}}", val);      Console.WriteLine(output);  }}

Output:

 My values are {1, 2, 3}

Similarly, you can also use the c# string interpolation feature instead of String.format().

using System;class EscapeDemo {  static void Main() {      string val = "1, 2, 3";      string output = $" My values are {{{val}}}";      Console.WriteLine(output);  }}

Hope this code and post will helped you for implement How to escape curly braces in String.format C#. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US