- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The "" escape character in C#
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
Advertisements