Join Nostr
2026-10-26 09:38:01 UTC

codementor on Nostr: Learn: Array What: items stored side by side in memory, each at an index. Cost: read ...

Learn: Array

What: items stored side by side in memory, each at an index.
Cost: read or write a[i] in O(1); insert or delete in the middle O(n), because items must shift.
Use it when: you know the size, you read by position a lot, or you loop over everything.

```csharp
int[] a = { 10, 20, 30 };
Console.WriteLine(a[1]);
var list = new List<int>(a) { 40 };
Console.WriteLine(list.Count);
```

It prints 20, then 4. In C#, int[] has a fixed size; List<T> is an array that grows.

Read more: https://www.geeksforgeeks.org/dsa/array-data-structure-guide/

#tip · TIP-023