Bird
0
0

Which of the following is the correct syntax to extract a substring starting at index 3 with length 5 from a string text?

easy📝 Syntax Q12 of 15
C Sharp (C#) - Strings and StringBuilder
Which of the following is the correct syntax to extract a substring starting at index 3 with length 5 from a string text?
Atext.Substring(3, 5);
Btext.SubString(5, 3);
Ctext.Substring(5);
Dtext.Substr(3, 5);
Step-by-Step Solution
Solution:
  1. Step 1: Recall Substring method signature

    Substring takes start index first, then length: Substring(int startIndex, int length).
  2. Step 2: Match correct syntax

    text.Substring(3, 5); uses correct method name and parameter order: start at 3, length 5.
  3. Final Answer:

    text.Substring(3, 5); -> Option A
  4. Quick Check:

    Correct method and parameters = text.Substring(3, 5); [OK]
Quick Trick: Remember: Substring(startIndex, length) with capital S [OK]
Common Mistakes:
MISTAKES
  • Using wrong method name like Substr or SubString
  • Swapping start index and length parameters
  • Using only one parameter when two are needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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