Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Mehrdimensionale Arrays | Arrays
C# Grundlagen

bookMehrdimensionale Arrays

main.cs

main.cs

copy
1
datatype[][] arrayName = new datatype[lengthX, lengthY];
main.cs

main.cs

copy
1
int[,] numbers = new int[3,3];
main.cs

main.cs

copy
12345
datatype [,] arrayName = { { element1, element2, ... }, { element1, element2, ...}, ... };
main.cs

main.cs

copy
12345678910111213141516171819202122
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int[,] numbers = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; // Displaying the array foreach (int number in numbers) { Console.Write(number + " "); } } } }
main.cs

main.cs

copy
1
arrayName[row, column];
main.cs

main.cs

copy
123456789101112131415161718
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int[,] numbers = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; Console.WriteLine(numbers[1, 2]); // Output: 7 } } }
main.cs

main.cs

copy
123
int[,,] myArray3D = new int[3, 4, 5]; int[,,,] myArray4D = new int[5, 4, 9, 10]; // Similarly more complex ones are possible as well using the same pattern
main.cs

main.cs

copy
123456
int[,,] numbers = { { {1, 2, 3}, { 4, 5, 6 }, {7, 8, 9} }, { {10, 11, 12}, {13, 14, 15}, {16, 17, 18} }, { {19, 20, 21}, {22, 23, 24}, {25, 26, 27} } };
question mark

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 5. Kapitel 5

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Awesome!

Completion rate improved to 1.59

bookMehrdimensionale Arrays

Swipe um das Menü anzuzeigen

main.cs

main.cs

copy
1
datatype[][] arrayName = new datatype[lengthX, lengthY];
main.cs

main.cs

copy
1
int[,] numbers = new int[3,3];
main.cs

main.cs

copy
12345
datatype [,] arrayName = { { element1, element2, ... }, { element1, element2, ...}, ... };
main.cs

main.cs

copy
12345678910111213141516171819202122
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int[,] numbers = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; // Displaying the array foreach (int number in numbers) { Console.Write(number + " "); } } } }
main.cs

main.cs

copy
1
arrayName[row, column];
main.cs

main.cs

copy
123456789101112131415161718
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int[,] numbers = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; Console.WriteLine(numbers[1, 2]); // Output: 7 } } }
main.cs

main.cs

copy
123
int[,,] myArray3D = new int[3, 4, 5]; int[,,,] myArray4D = new int[5, 4, 9, 10]; // Similarly more complex ones are possible as well using the same pattern
main.cs

main.cs

copy
123456
int[,,] numbers = { { {1, 2, 3}, { 4, 5, 6 }, {7, 8, 9} }, { {10, 11, 12}, {13, 14, 15}, {16, 17, 18} }, { {19, 20, 21}, {22, 23, 24}, {25, 26, 27} } };
question mark

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 5. Kapitel 5
some-alt