+ 3
Array vs Collection in C#
I know, that in C#a collection can change its length dinamically, but that leads to the question what the benefits of an array over a (dictionary) collection is. Hope this question isn't that stupid ;D
4 Answers
+ 9
First of all, I believe you're referring to List<T> in C# instead of Dictionary<TKey, TValue> as the latter is a list of key-value pair.
As you might already know, an array always have a fixed size and the convenience of flexible size of list comes with a trade-off in terms of performance.
Therefore, use an Array if you are certain the size beforehand and List in any other cases.
Hopefully it helps! š
+ 1
Well, arrays are somewhat faster.It's all about performance.
+ 1
Alright then, thank you guys for the fast answer :)
0
Exactly :)