0
0
C Sharp (C#)programming~5 mins

List generic collection in C Sharp (C#) - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a List<T> in C#?
A List<T> is a generic collection in C# that stores elements of the same type in a dynamic array. It can grow or shrink as needed.
Click to reveal answer
beginner
How do you add an item to a List<T>?
Use the Add() method. For example: myList.Add(item); adds item to the end of the list.
Click to reveal answer
beginner
How do you access an element at a specific position in a List<T>?
Use the indexer with square brackets. For example: myList[0] accesses the first element.
Click to reveal answer
intermediate
What happens if you try to access an index outside the List<T> range?
An ArgumentOutOfRangeException is thrown because the index is invalid.
Click to reveal answer
beginner
How can you find the number of elements in a List<T>?
Use the Count property. For example: int size = myList.Count;
Click to reveal answer
Which method adds an element to a List<T>?
ARemove()
BAdd()
CInsert()
DClear()
How do you get the number of elements in a List<T>?
ALength
BSize
CCapacity
DCount
What type of collection is List<T>?
ALinked list
BFixed-size array
CGeneric dynamic array
DDictionary
What happens if you access myList[10] when myList has 5 elements?
AThrows ArgumentOutOfRangeException
BReturns default value
CReturns null
DReturns last element
Which of these methods removes all elements from a List<T>?
AClear()
BRemove()
CDelete()
DDrop()
Explain what a List<T> is and how it differs from a regular array.
Think about flexibility and type safety.
You got /4 concepts.
    Describe how to add, access, and count elements in a List<T>.
    Focus on common operations with List&lt;T&gt;.
    You got /3 concepts.