Bird
0
0

Which of the following is the correct syntax for interpolating a variable named 'score' in a string?

easy📝 Syntax Q3 of 15
C Sharp (C#) - Strings and StringBuilder
Which of the following is the correct syntax for interpolating a variable named 'score' in a string?
A"Your score is {score}"
B$"Your score is $score"
C"Your score is $score"
D$"Your score is {score}"
Step-by-Step Solution
Solution:
  1. Step 1: Check interpolation syntax

    Interpolation requires $ before the string and braces around variable.
  2. Step 2: Match correct option

    $"Your score is {score}" correctly uses $ and {score} inside the string.
  3. Final Answer:

    $"Your score is {score}" -> Option D
  4. Quick Check:

    Correct interpolation = $ + {variable} [OK]
Quick Trick: Use braces {} around variables inside $ strings [OK]
Common Mistakes:
MISTAKES
  • Forgetting braces around variable
  • Placing $ inside the string quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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