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

Why collections over arrays in C Sharp (C#) - Quick Recap

Choose your learning style9 modes available
Recall & Review
beginner
What is a key limitation of arrays compared to collections in C#?
Arrays have a fixed size, meaning once created, their length cannot change. Collections can grow or shrink dynamically.
Click to reveal answer
beginner
How do collections improve code flexibility over arrays?
Collections provide methods to add, remove, and search items easily, making code more adaptable to changing data.
Click to reveal answer
beginner
Name a common collection type in C# that is preferred over arrays for dynamic data.
List<T> is a common collection that allows dynamic resizing and easy manipulation of elements.
Click to reveal answer
intermediate
Why might you choose an array over a collection in C#?
Arrays can be more efficient in memory and performance when the size is fixed and known in advance.
Click to reveal answer
intermediate
Explain how collections support better code readability compared to arrays.
Collections have built-in methods with clear names like Add, Remove, and Contains, making code easier to understand than manual array management.
Click to reveal answer
Which of the following is true about arrays in C#?
AThey have a fixed size once created.
BTheir size can be changed after creation.
CThey provide built-in methods like Add and Remove.
DThey are always slower than collections.
What is a main advantage of using List<T> over arrays?
AList<T> has a fixed size.
BList<T> can dynamically resize and has helpful methods.
CList<T> uses less memory than arrays.
DList<T> cannot store objects.
When might arrays be preferred over collections?
AWhen data size changes frequently.
BWhen you need dynamic resizing.
CWhen you want to use Add and Remove methods.
DWhen performance and fixed size are important.
Which collection method is NOT available in arrays?
AIndexing
BLength
CAdd
DIteration
Why do collections improve code readability?
AThey have clear method names for common actions.
BThey do not support iteration.
CThey require manual size management.
DThey use complex syntax.
Explain why collections are often preferred over arrays in C# programming.
Think about how easy it is to change the number of items.
You got /4 concepts.
    Describe a scenario where using an array might be better than a collection.
    Consider when data size does not change.
    You got /3 concepts.