Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a verbatim string literal in C#?
A verbatim string literal starts with @ and allows the string to include backslashes and new lines exactly as typed, without needing escape sequences.
Click to reveal answer
beginner
How do you write a multi-line string in C# using verbatim literals?
Use @ before the opening quote and write the string across multiple lines. For example:
@"Line 1
Line 2"
preserves the line breaks.
Click to reveal answer
intermediate
What is a raw string literal in C# 11 and later?
A raw string literal uses triple quotes ("""), allowing multi-line strings with no escape sequences, preserving all characters exactly as typed.
Click to reveal answer
intermediate
How do you include double quotes inside a verbatim string literal?
Double the double quotes inside the string. For example:
@"She said, ""Hello!"""
outputs: She said, "Hello!"
Click to reveal answer
intermediate
What is the main difference between verbatim and raw string literals in C#?
Verbatim strings start with @ and require doubling quotes to escape them, while raw string literals use triple quotes and allow easier multi-line strings with embedded quotes without doubling.
Click to reveal answer
Which symbol starts a verbatim string literal in C#?
A$
B#
C@
D"""
✗ Incorrect
Verbatim strings start with @ before the opening quote.
How do you write a raw string literal in C# 11?
AUse triple double quotes """
BUse @ before the string
CUse single quotes
DUse backticks `
✗ Incorrect
Raw string literals use triple double quotes """ to start and end the string.
How do you include a double quote inside a verbatim string literal?
ADouble the double quotes ""
BYou cannot include double quotes
CUse single quotes '"'
DEscape with a backslash \"
✗ Incorrect
Inside verbatim strings, double quotes are included by doubling them.
Which of these is true about raw string literals?
AThey require escaping backslashes
BThey start with @
CThey cannot span multiple lines
DThey preserve all characters exactly as typed
✗ Incorrect
Raw string literals preserve all characters exactly as typed, including new lines and quotes.
What is the output of this verbatim string? @"C:\Users\Admin"
AC:UsersAdmin
BC:\Users\Admin
CC:/Users/Admin
DError
✗ Incorrect
Verbatim strings treat backslashes literally, so the output is C:\Users\Admin with single backslashes.
Explain how verbatim string literals work in C# and how they help with file paths.
Think about how Windows file paths use backslashes.
You got /4 concepts.
Describe the advantages of raw string literals introduced in C# 11 compared to verbatim strings.
Consider how raw strings simplify writing complex strings.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a verbatim string literal in C# (starting with @)?
easy
A. To write strings that ignore escape sequences and can span multiple lines easily.
B. To create strings that automatically convert to uppercase.
C. To define strings that are encrypted at compile time.
D. To declare strings that are immutable and cannot be changed.
Solution
Step 1: Understand verbatim string syntax
Verbatim strings start with @ and allow writing strings with backslashes and new lines without escape sequences.
Step 2: Identify the purpose
This makes writing file paths and multi-line text easier and more readable.
Final Answer:
To write strings that ignore escape sequences and can span multiple lines easily. -> Option A
Quick Check:
Verbatim strings ignore escapes = A [OK]
Hint: Verbatim strings start with @ and ignore escape sequences [OK]
Common Mistakes:
Thinking verbatim strings convert text case
Assuming verbatim strings encrypt content
Confusing immutability with verbatim syntax
2. Which of the following is the correct syntax for a raw string literal in C# 11+?
easy
A. """This is a raw string"""
B. @"This is a raw string"
C. 'This is a raw string'
D. "This is a raw string"
Solution
Step 1: Recall raw string literal syntax
Raw string literals in C# 11+ use triple double quotes to start and end the string.
Step 2: Compare options
"""This is a raw string""" uses triple double quotes correctly; @"This is a raw string" is verbatim string syntax, not raw string.
Final Answer:
"""This is a raw string""" -> Option A
Quick Check:
Raw strings use triple quotes = D [OK]
Hint: Raw strings use triple quotes """ at start and end [OK]
Common Mistakes:
Confusing verbatim strings (@) with raw strings (""")
Using single quotes for strings
Using normal double quotes for raw strings
3. What will be the output of this C# code?
string path = @"C:\Users\Admin";
string raw = """C:\Users\Admin""";
Console.WriteLine(path);
Console.WriteLine(raw);
medium
A. C:\\Users\\Admin
C:\\Users\\Admin
B. C:\Users\Admin
C:\Users\Admin
C. C:UsersAdmin
C:UsersAdmin
D. C:\UsersAdmin
C:\Users\Admin
Solution
Step 1: Understand verbatim string output
The verbatim string @"C:\Users\Admin" outputs the path with single backslashes because escapes are ignored.
Step 2: Understand raw string output
The raw string """C:\Users\Admin""" preserves the backslashes exactly as typed, so output is the same.
Final Answer:
C:\Users\Admin
C:\Users\Admin -> Option B
Quick Check:
Both print path with single backslashes = B [OK]
Hint: Both verbatim and raw strings preserve backslashes as typed [OK]
Common Mistakes:
Expecting double backslashes in output
Confusing escape sequences in verbatim strings
Thinking raw strings remove backslashes
4. Identify the error in this code snippet:
string text = @"This is a "quoted" word.";
medium
A. Raw string literals require triple quotes, not @.
B. Verbatim strings cannot contain double quotes.
C. No error, code is correct.
D. Missing escape for inner quotes inside verbatim string.
Solution
Step 1: Check verbatim string rules for quotes
In verbatim strings, double quotes inside must be doubled to escape them ("" for one ").
Step 2: Identify the error
The code uses single double quotes inside verbatim string, causing syntax error.
Final Answer:
Missing escape for inner quotes inside verbatim string. -> Option D
Quick Check:
Double quotes inside verbatim need doubling = C [OK]