Challenge - 5 Problems
String Literal Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of verbatim string with escape sequences
What is the output of this C# code snippet?
C Sharp (C#)
string path = @"C:\Users\Admin\Documents";
Console.WriteLine(path);Attempts:
2 left
💡 Hint
Remember that verbatim strings treat backslashes as normal characters.
✗ Incorrect
The @ symbol before the string makes it verbatim, so backslashes are not escape characters but literal backslashes.
❓ Predict Output
intermediate2:00remaining
Output of raw string literal with multiple lines
What will this C# code print?
C Sharp (C#)
string json = """ { "name": "Alice", "age": 30 } """; Console.WriteLine(json);
Attempts:
2 left
💡 Hint
Raw string literals preserve all whitespace and line breaks exactly.
✗ Incorrect
Raw string literals keep the text exactly as typed, including new lines and quotes without needing escapes.
🔧 Debug
advanced2:00remaining
Identify the error in verbatim string usage
What error will this code produce?
C Sharp (C#)
string text = @"This is a "quoted" word.";
Attempts:
2 left
💡 Hint
How do you include double quotes inside a verbatim string?
✗ Incorrect
Inside verbatim strings, double quotes must be doubled to be included literally.
❓ Predict Output
advanced2:00remaining
Output of raw string literal with embedded quotes
What is the output of this C# code?
C Sharp (C#)
string poem = """""Roses are red, "Violets" are blue. """""; Console.WriteLine(poem);
Attempts:
2 left
💡 Hint
Raw string literals can contain quotes without escaping if the delimiter count is sufficient.
✗ Incorrect
The raw string literal uses 5 quotes as delimiter, so inner quotes are preserved as is without escapes or delimiters.
🧠 Conceptual
expert2:00remaining
Difference between verbatim and raw string literals
Which statement correctly describes the difference between verbatim (@) and raw (""""" or more quotes) string literals in C#?
Attempts:
2 left
💡 Hint
Think about how each treats backslashes, new lines, and quotes.
✗ Incorrect
Verbatim strings treat backslashes literally but still require doubling quotes. Raw strings preserve everything exactly, including new lines and quotes, without escapes.