Escape Curly Brace In C# String.Format()
To escape curly braces in String.Format(), you have to prepend "{" symbol in the opening brace and append "}" in the closing brace as shown below.
Code:
Output:
Code:
string firstName = "Michael"; string lastName = "Jordan"; string output = String.Format("Your name is: {{ {0}, {1} }}", firstName, lastName); Console.WriteLine(output);
Comments
Post a Comment