Donate

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:
string firstName = "Michael";
string lastName = "Jordan";
string output = String.Format("Your name is: {{ {0}, {1} }}", firstName, lastName);
Console.WriteLine(output);
Output: Escape Curly Brace In C# String.Format()

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.