The "#", "0", ".", ",", "%", and "‰" symbols in a format string are interpreted as format specifiers.
Prevent a character from being interpreted as a format specifier, by preceding it with an escape character i.e. backslash.
To prevent interpreting as an escape character, use escape character for #", "0", and "\" characters.
Let us see an example −
Here, we are displaying #, by preceding it with an escape character i.e. backslash.
Example
using System;
using System.Globalization;
class Demo {
static void Main() {
int num = 20;
Console.WriteLine(num.ToString("\\#\\# ##0 Rank"));
}
}Output
## 20 Rank