Bird
0
0

What is the output of this C# code?

medium📝 Predict Output Q4 of 15
C Sharp (C#) - Strings and StringBuilder
What is the output of this C# code?
string path = @"C:\Users\Admin";
string raw = """C:\Users\Admin""";
Console.WriteLine(path == raw);
ACompilation error
BTrue
CFalse
DRuntime exception
Step-by-Step Solution
Solution:
  1. Step 1: Understand string values assigned

    Both strings represent the same text: C:\Users\Admin. Verbatim string uses @ and escapes backslash by doubling, raw string uses triple quotes and literal backslashes.
  2. Step 2: Compare the two strings

    Since both strings contain identical text, the equality check returns true.
  3. Final Answer:

    True -> Option B
  4. Quick Check:

    Verbatim and raw strings with same content = equal [OK]
Quick Trick: Verbatim and raw strings can represent same text differently [OK]
Common Mistakes:
MISTAKES
  • Assuming raw strings interpret escape sequences
  • Thinking equality check returns false due to syntax
  • Confusing raw string triple quotes with verbatim syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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