Recall & Review
beginner
What is a string literal in C#?
A string literal is a sequence of characters enclosed in double quotes, like "Hello". It represents a fixed string value in the code.
Click to reveal answer
beginner
How do you create a verbatim string literal in C#?
By prefixing the string with @, like @"C:\Users\Name". It treats backslashes and newlines as literal characters without needing escape sequences.
Click to reveal answer
intermediate
What is the difference between a regular string literal and a verbatim string literal?
Regular string literals use escape sequences (like \n for newline). Verbatim string literals (with @) treat the string exactly as typed, including backslashes and newlines.
Click to reveal answer
intermediate
Can you use double quotes inside a verbatim string literal? How?
Yes, by doubling the double quotes inside the string. For example: @"She said, ""Hello""." represents She said, "Hello".
Click to reveal answer
beginner
What type does a string literal have in C#?
A string literal has the type System.String, which is an alias for the keyword string in C#.
Click to reveal answer
Which of the following is a valid verbatim string literal in C#?
✗ Incorrect
Option A uses @ to create a verbatim string literal, so backslashes are treated literally without needing double escaping.
How do you represent a newline character in a regular string literal?
✗ Incorrect
In regular string literals, \n is the escape sequence for a newline character.
What happens if you write @"Hello "World"" in C#?
✗ Incorrect
Double quotes inside a verbatim string must be doubled to escape them. Writing @"Hello "World"" causes a compilation error.
Which keyword is an alias for System.String in C#?
✗ Incorrect
The keyword string is an alias for System.String in C#.
Which of these is NOT a valid way to create a string in C#?
✗ Incorrect
Single quotes are for char literals, not strings. So 'Hello' is invalid for a string.
Explain how to create and use verbatim string literals in C# and why they are useful.
Think about file paths and multiline text.
You got /4 concepts.
Describe the difference between regular string literals and verbatim string literals in C#.
Consider how newlines and backslashes are handled.
You got /3 concepts.