Bird
0
0

What will be the output of this C# code?

medium📝 Predict Output Q13 of 15
C Sharp (C#) - Strings and StringBuilder
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);
AC:\\Users\\Admin C:\\Users\\Admin
BC:\Users\Admin C:\Users\Admin
CC:UsersAdmin C:UsersAdmin
DC:\UsersAdmin C:\Users\Admin
Step-by-Step Solution
Solution:
  1. Step 1: Understand verbatim string output

    The verbatim string @"C:\Users\Admin" outputs the path with single backslashes because escapes are ignored.
  2. Step 2: Understand raw string output

    The raw string """C:\Users\Admin""" preserves the backslashes exactly as typed, so output is the same.
  3. Final Answer:

    C:\Users\Admin C:\Users\Admin -> Option B
  4. Quick Check:

    Both print path with single backslashes = B [OK]
Quick Trick: Both verbatim and raw strings preserve backslashes as typed [OK]
Common Mistakes:
MISTAKES
  • Expecting double backslashes in output
  • Confusing escape sequences in verbatim strings
  • Thinking raw strings remove backslashes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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