I know we can escape curly bracket in C# using {{
and }}
. But they don't seem to work well if they are right after a format modifier (like {0:F6}
).
string str;
// Prints "{3.14}" as expected
str = string.Format("{{{0}}}", 3.14);
Console.WriteLine(str);
// Expected "{3.140000}", found "{F6}"
str = string.Format("{{{0:F6}}}", 3.14);
Console.WriteLine(str);
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Full form of C is “COMPILE”. One thing which was missing in C language was further added to C++ that is 'the concept of CLASSES'.
C is a procedural language that provides no support for objects and classes. C++ is a combination of OOP and procedural programming languages. C has 32 keywords and C++ has 63 keywords. C supports built-in data types, while C++ supports both built-in and user-defined data types.
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
This is how C# processes curly brackets, it's well known. See here
You can escape it like this (for example, there are different ways):
var str = string.Format("{0}{1:F6}{2}", "{", 3.14, "}");
Console.WriteLine(str);
Try this:
String.Format("{0}{1:F6}{2}", "{",3.14, "}")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With