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
Published at
2026-10-26 09:38:01 UTCEvent JSON
{
"id": "f3c0c2ef4cf63c687c6c7569dc5c1fd7ae54ab1796831f92a8a421c88eba9056",
"pubkey": "e68a0856e90d9997b1f721e905249896412dd570399a987b2e8fd5e7fcfe2279",
"created_at": 1793007481,
"kind": 1,
"tags": [
[
"t",
"tip"
]
],
"content": "Learn: Array\n\nWhat: items stored side by side in memory, each at an index.\nCost: read or write a[i] in O(1); insert or delete in the middle O(n), because items must shift.\nUse it when: you know the size, you read by position a lot, or you loop over everything.\n\n```csharp\nint[] a = { 10, 20, 30 };\nConsole.WriteLine(a[1]);\nvar list = new List\u003cint\u003e(a) { 40 };\nConsole.WriteLine(list.Count);\n```\n\nIt prints 20, then 4. In C#, int[] has a fixed size; List\u003cT\u003e is an array that grows.\n\nRead more: https://www.geeksforgeeks.org/dsa/array-data-structure-guide/\n\n#tip · TIP-023",
"sig": "ec39b8921427cff5afd76e17069c7fc22e9ac5c06c245cdc653e0fa4ca8d52af0db6532731945f52e5cd516470a7d0a18771448fee97f089c9b1765d0b330f9f"
}