C# multidimensional arrays ⬜

preview_player
Показать описание
C# multidimensional 2D arrays tutorial example explained

#C# #multidimensional #arrays
Рекомендации по теме
Комментарии
Автор

using System;

namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{

String[, ] parkingLot = { { "Mustang", "F-150", "Explorer" },
{ "Corvette", "Camaro", "Silverado" },
{ "Corolla", "Camry", "Rav4" }
};

parkingLot[0, 2] = "Fusion";
parkingLot[2, 0] = "Tacoma";
/*
foreach(String car in parkingLot)
{
Console.WriteLine(car);
}
*/
for(int i = 0; i < parkingLot.GetLength(0); i++)
{
for (int j = 0; j < parkingLot.GetLength(1); j++)
{
Console.Write(parkingLot[i, j] + " ");
}
Console.WriteLine();
}

Console.ReadKey();
}
}
}

BroCodez
Автор

I can't thank you enough for making this video. This might get buried in the comments, but I always find myself coming back to your videos for help.

bakastep
Автор

Thanks! I like the short videos like this about smaller subjects. Sometimes I just need a refresher and not an hour long thing about it.

expansivegymnast
Автор

thanks! i was confused by the training explanation in my course, and this explained exactly what I was confused by their wording!

e.dnorth
Автор

Short sweet and to the point. Just the refresher I needed

crazydave
Автор

Thanks alot dude, 1st year game developer here, so your videos help alot when my lecturers dont feel like answering my freshman questions anymore

ninjanick
Автор

Had a tough time trying to understand multidimensional arrays in class, but I easily understood them straight away when I watched this video. You're the best Bro💯

LincyMcGabby
Автор

This is a great video! In my SoloLearn course I was confused by their introduction of {2, 3} bracketed values into the multidimensional array exercise and how that effected the rows and columns in the index. Prior they had been using [8, 8] code to set the rows and columns.

krevin
Автор

Wonderful, but I rather use "type[ ][ ]" instead of "type[, ]", so it's easier to make dynamic irregular matrix if i want to :)

fushitensho
Автор

I feel like it should be illegal to watch something this good for free

definitelynotchris
Автор

Hey! i know you wont see this message but ive learned C# from you, thank you!

HishamButt-uerc
Автор

For 2D array :

String[, ] array_2D = {
{"x0y0", "x1y0"}, // y0
{"x0y1", "x1y1"}, // y1
};
// just like a table in coordinate system .


for (int y=0; y<array_2D.GetLength(0); y++)
{
for (int x=0; x<array_2D.GetLength(1); x++)
{
Console.WriteLine(array_2D[y, x]);
}
}
/*
foreach (String a in array_2D)
{
Console.WriteLine(a);
}
*/

->
x0y0
x1y0
x0y1
x1y1

For 3D array :

String[, , ] array_3D = {
{ // z0
{"x0y0z0", "x1y0z0"}, // y0
{"x0y1z0", "x1y1z0"} // y1
},
{ // z1
{"x0y0z1", "x1y0z1"}, // y0
{"x0y1z1", "x1y1z1"} // y1
}
};

for (int z=0; z<array_3D.GetLength(0); z++)
{
for (int y=0; y<array_3D.GetLength(1); y++)
{
for (int x=0; x<array_3D.GetLength(1); x++)
{
Console.WriteLine(array_3D[z, y, x]);
}
}
}
/*
foreach (String a in array_3D)
{
Console.WriteLine(a);
}
*/

->
x0y0z0
x1y0z0
x0y1z0
x1y1z0
x0y0z1
x1y0z1
x0y1z1
x1y1z1

maxwong
Автор

wow that`s a long way actually, week number 2 and lesson number 30 brooo. thank you for help, i start to understand something now

anatolii
Автор

I think in the for statement: onter loop for lows and inner loop for colums

asrbekmirsoatov
Автор

i love you so much bro TT
helping me pass my degree

jay-leeshih
Автор

Wow this is pretty complicated! I cant believe this is counted as intermediate. I wonder what advanced topics will be

duck
Автор

Thanks so much it was really useful for me

Alexhusen
Автор

Thanks for help making me understand! Also sweet name

tuckbuckk
Автор

bro looks like a certified car geek.(Me also)

rishitkumar
Автор

Why the output declared the 3 elements of 0, 1, and 2 array? He just used 0 and 1 array in his for loop condition, but he got those 3 elements of 0, 1, 2 array instead of 0, 1 array only.. I'm confused about it.. Anyone can help me to understand that last part of the video?

kimiannalapo