C# Arrays Vs Lists

Arrays and Lists are very similar data types in C#. Here’s a quick comparison with nice dot-points.

Define some Arrays and Lists

Arrays:

  • Are better for collections of data that won’t be added to or removed from during runtime.
  • Can be multi-dimensional.
  • Are a method to group and organize data.
  • are collections whose elements are accessed through an “index”: An integer, starting from zero, which corresponds to the element’s order in the array.
  • Use statically-allocated memory, less suited to runtime modification.
  • Store their data in a continuous memory allocation.

Lists:

  • Can be added to or removed from easily during runtime.
  • Are a method to group and organize data that allows for more modification operations to the data and itself.
  • are collections whose elements can be accessed through an “index”: An integer, starting from zero, which corresponds to the element’s order in the array.
  • Use dynamically assigned memory, allotted on request, significantly limiting or negating memory waste.
  • Store their data in non-continuous memory allocations, where bits of data are scattered around memory, while maintaining links together.

This is just a basic intro into C# Lists and Arrays, but I find the easiest way to think of them is like this:

That will be enough to get through most situations requiring a collection of data, but for more advanced projects and usages, you’d need to understand a little more.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vincent Taylor

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.