Bird
0
0

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

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

    The correct syntax requires specifying the type in angle brackets and using the new keyword with constructor.
  2. Step 2: Check each option

    List numbers = new List(); correctly declares and initializes a List of integers.
  3. Final Answer:

    List numbers = new List(); -> Option D
  4. Quick Check:

    Correct List syntax = D [OK]
Quick Trick: Use new keyword and specify type in angle brackets [OK]
Common Mistakes:
MISTAKES
  • Omitting new keyword
  • Not specifying generic type
  • Using wrong constructor syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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