Welcome back.
In this video you are going to learn how to use special characters inside of strings.
And therefore I'm going to create a new string that I'm going to call S1.
And it's going to say this is a string with a slash and a colon.
Okay.
So just as usual, we end this with a semicolon.
Now let me print it out with c w tab.
And I get this console right line.
And I can just say write as one for me.
And let's run this and we will see that we get this is a string with a slash and a colon.
However, some characters have special meaning in strings.
These are called escape characters.
For example, the double quote character is used to denote the start and end of a string.
If you want to include a double quote inside a string, you need to escape it using the backslash.
So if I were to use this quotation here, you see, suddenly I get an error in my code and it doesn't
work.
So if I want to say something like string like this inside of my text, then I'm going to run into an
error inside of the compiler.
It says syntax error.
A comma is expected, so I could use concatenation here, but what I can do instead is I can use the
backslash which is an escape character.
So now I can use backslash here as well.
And what it will do is it will treat the quotation marks as part of the string, and not as part of
the code that the compiler needs to compile.
So now let me run this again.
And you can see this is a string with a slash and a colon.
So I basically just have to use the backslash in order to use characters that are otherwise used in
C sharp for writing code specifically.
Now if I were to use a backslash.
So let me say backslash here, then I have to use the double backslash for example.
So I have a backslash to escape the other backslash because otherwise the backslash also creates an
error for us inside of Visual Studio.
Okay.
So now let me run this code to give you an idea.
And you see we have a double backslash here.
But we only see one backslash because the other one is used as an escape character.
There is one special escape sequence that is the backslash n.
So after the with a I'm going to have a backslash n.
This backslash n will create a new line.
So the text will not be.
This is a string with an a backslash.
But it will say this is a string with and then this will generate a line break.
And then in the next line it will say a backslash and a colon.
So let's run this and you see this is a string with empty space.
This is this empty space here.
And then we have a line break.
And then it says a backslash and a colon.
So that's pretty much what you should know about escape characters and the backslash n, which is an
escape sequence.