Bird
0
0

What will be the output of this C# code?

medium📝 Predict Output Q5 of 15
C Sharp (C#) - Strings and StringBuilder
What will be the output of this C# code?
string s = "Hello\tWorld";
Console.WriteLine(s);
AHello\tWorld
BHello World
CHello World
DHello\World
Step-by-Step Solution
Solution:
  1. Step 1: Understand escape sequence \t

    \t represents a tab character which adds horizontal space.
  2. Step 2: Predict Console.WriteLine output

    The output will be Hello followed by a tab space then World, which appears as multiple spaces.
  3. Final Answer:

    Hello World -> Option B
  4. Quick Check:

    \t = tab space in normal strings [OK]
Quick Trick: Use \t for tab space inside normal strings [OK]
Common Mistakes:
MISTAKES
  • Expecting \t to print literally
  • Confusing verbatim and normal strings
  • Ignoring escape sequences

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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