Bird
0
0

Which of the following is the correct syntax for a verbatim string literal in C#?

easy📝 Syntax Q3 of 15
C Sharp (C#) - Strings and StringBuilder
Which of the following is the correct syntax for a verbatim string literal in C#?
Astring s = @"Hello World";
Bstring s = "@Hello\nWorld";
Cstring s = "Hello\nWorld@";
Dstring s = @"Hello\nWorld";
Step-by-Step Solution
Solution:
  1. Step 1: Identify verbatim string syntax

    Verbatim strings start with @ before the opening quote and do not interpret escape sequences like \n.
  2. Step 2: Check each option

    string s = @"Hello\nWorld"; correctly shows @"Hello\nWorld" where \n is literal characters, not newline.
  3. Final Answer:

    string s = @"Hello\nWorld"; -> Option D
  4. Quick Check:

    Verbatim string syntax = @ before quotes [OK]
Quick Trick: Verbatim strings start with @ before the opening quote [OK]
Common Mistakes:
MISTAKES
  • Placing @ inside the quotes
  • Using backslash escapes inside verbatim strings
  • Missing @ symbol before quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes