From the course: C#: String Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Use escape sequences to add control chars to a string - C# Tutorial
From the course: C#: String Essential Training
Use escape sequences to add control chars to a string
- [Instructor] Escape sequences are used to represent non-printable and special characters in string literals. They were originally used to send commands to hardware devices like printers and display terminals. They are still useful, we can use them for putting tabs and new lines and special characters within a string literal. The way you create an escape sequence within the string literal, it's always inside the string literal, so you start with your double quotes, and then you use the backslash to indicate the start of an escape sequence. So if I want to put a apostrophe, or a single quote, inside a string, I could use the escape sequence like this. I want to put a double quote in the string, I use \". And of course, if I need to put a backslash in my code, I use two backslashes together. So let's see what we're doing on line 39. I'm declaring a string variable, I'm starting with the double quote, this is the double quote…