Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have Arrays in .NET lost their significance?

For every situation that warrants the use of an array ... there is an awesome collection with benefits. Is there any specific use case for Arrays any more in .NET?

like image 987
GilliVilla Avatar asked Sep 11 '10 18:09

GilliVilla


People also ask

Is it better to use array or list C#?

In general, it's better to use lists in C# because lists are far more easily sorted, searched through, and manipulated in C# than arrays. That's because of all of the built-in list functionalities in the language.

Are arrays immutable in C#?

An array is not immutable, even if the elements it holds are immutable. So if an array slot holds a string, you can change it to a different string. This does not change any of the strings, it just changes the array.

Why are lists better than arrays?

The list is better for frequent insertion and deletion, whereas Arrays are much better suited for frequent access of elements scenario. List occupies much more memory as every node defined the List has its own memory set whereas Arrays are memory-efficient data structure.

When should I use an array instead of a list?

Arrays can store data very compactly and are more efficient for storing large amounts of data. Arrays are great for numerical operations; lists cannot directly handle math operations. For example, you can divide each element of an array by the same number with just one line of code.


1 Answers

Sending/Receiving data with a specific length comes to mind, ie. Serial Port, Web Request, FTP Request. Basically stuff that works on a lower level in the system. Also, most Collections are using an array for storage (Noteable exception: LinkedList<T>). Collections are just another abstraction layer.

like image 156
Femaref Avatar answered Oct 09 '22 12:10

Femaref