You just need to escape it:
char c="\\";
Or you could use the Unicode escape sequence:
char c="\u005c";
See my article on strings for all the various escape sequences available in string/character literals.
More Related Contents:
- Can I escape a double quote in a verbatim string literal?
- Can I convert a C# string value to an escaped string literal?
- Unrecognized escape sequence for path string containing backslashes
- Escape Special Character in Regex
- Escape invalid XML characters in C#
- String escape into XML
- How to escape JSON string?
- Escape text for HTML
- @(at) sign in file path/string [duplicate]
- Escape Quote in C# for javascript consumption
- Convert XmlDocument to String
- Finding quoted strings with escaped quotes in C# using a regular expression
- How can I Unescape and Reescape strings in .net?
- C# – What does “\0” equate to?
- Change default app.config at runtime
- Call one constructor from another
- Should functions return null or an empty object?
- How can I extract a file from an embedded resource and save it to disk?
- SqlDataAdapter vs SqlDataReader
- Can a unit test project load the target application’s app.config file?
- How do I target attributes for a record class?
- What do programmers mean when they say, “Code against an interface, not an object.”?
- HTML agility pack – removing unwanted tags without removing content?
- When should I create a new DbContext()
- Perform screen-scape of Webbrowser control in thread
- multiple awaits vs Task.WaitAll – equivalent?
- Reading an int that’s updated by Interlocked on other threads
- Fluent NHibernate, working with interfaces
- Bold text in MessageBox
- Setting a proxy for Chrome Driver in Selenium