C# Programming Tutorial 42 - Iterate 2D and Jagged Array

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

It's very rare that you'll know what needs to be in an array at instantiation, or even want to manually set your values like this. examples maybe a preset map, handmade lowbit images, and dummy code, are the only use case I can think of, when you're usually setting it dynamically in the for loop, anyone who wants a quick ref you're usually going to do something like this
int arrayHeight = 15;
int arrayWidth = 10;
int[][] jaggedArray = new int[arrayHeight][];
// you could do something like this

for (int y = 0; y < arrayHeight; y++)
{
jaggedArray[y] = new int[arrayWidth];
for (int x = 0; x < arrayWidth; x++)
{
jaggedArray[y][x] = someValue;
}
}

mycollegeshirt
Автор

how do I add an element with the array already created? in jagged arrays. like adding another row

elaprimo
Автор

This is so much simpler than C++, lol

SuperPint