Bird
Raised Fist0

Which of the following is the correct syntax to declare a List of strings in C#?

easy📝 Syntax Q3 of Q15
C Sharp (C#) - Collections
Which of the following is the correct syntax to declare a List of strings in C#?
AList<string> names = List<string>();
BList names = new List<string>();
CList<string> names = new List<string>();
DList<string> names = new List();
Step-by-Step Solution
Solution:
  1. Step 1: Review correct generic List declaration

    Generic List requires specifying type in declaration and constructor with new keyword.
  2. Step 2: Check each option

    List names = new List(); correctly uses List names = new List(); others miss new, type, or constructor syntax.
  3. Final Answer:

    List names = new List(); -> Option C
  4. Quick Check:

    Correct List declaration = List names = new List(); [OK]
Quick Trick: Always use new List() to create a list [OK]
Common Mistakes:
MISTAKES
  • Omitting new keyword
  • Not specifying generic type
  • Incorrect constructor call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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