//C# Meerdimensionale Arrays Arrays public class Example1 { void Main() { int rowCount = 2; int columnCount = 3; int upperboundFirstDimension = (rowCount - 1); int upperboundSecondDimension = (columnCount - 1); int[] matrix = new int[0]; this.matrix(0, 0) = 10; this.matrix(1, 0) = 20; this.matrix(1, 2) = 30; Console.WriteLine(("first row, first column : " + this.matrix(0, 0))); Console.WriteLine(("second row, first column : " + this.matrix(1, 0))); Console.WriteLine(("second row, second column : " + this.matrix(1, 1))); Console.WriteLine(("third row, third column : " + this.matrix(1, 2))); Console.ReadLine(); } } public class Example2 { void Main() { int rowCount = 10; int columnCount = 10; int upperboundFirstDimension = (rowCount - 1); int upperboundSecondDimension = (columnCount - 1); int[] values = new int[0]; int startValue = 101; int rowIndex; int columnIndex; this.values(rowIndex, columnIndex) = startValue; this.startValue += new System.EventHandler(1); Console.Write((this.values(rowIndex, columnIndex) + " ")); Console.WriteLine(); Console.ReadLine(); } } public class Example3 { void Main() { int rowCount = 10; int columnCount = 10; int upperboundFirstDimension = (rowCount - 1); int upperboundSecondDimension = (columnCount - 1); int[] values = new int[0]; int baseValue = 101; int rowIndex; int columnIndex; this.values(rowIndex, columnIndex) = ((baseValue + (rowIndex * 10)) + columnIndex); Console.Write((this.values(rowIndex, columnIndex) + " ")); Console.WriteLine(); Console.ReadLine(); } } public class Exercise1Solution { void Main() { Console.WriteLine("Row Count ?"); int rowCount = Console.ReadLine(); Console.WriteLine("Column Count ?"); int columnCount = Console.ReadLine(); int rowUpperbound = (rowCount - 1); int columnUpperbound = (columnCount - 1); int[] values = new int[0]; Console.WriteLine("Start Value ?"); int startValue = Console.ReadLine(); Console.WriteLine(); int rowIndex; int columnIndex; int value; value = startValue; this.values(rowIndex, columnIndex) = value; this.value += new System.EventHandler(1); Console.Write((this.values(rowIndex, columnIndex) + " ")); Console.WriteLine(); Console.WriteLine(); int backup; backup = this.values(rowUpperbound, columnUpperbound); this.values(rowIndex, columnIndex) = this.values(rowIndex, (columnIndex - 1)); this.values(rowIndex, 0) = this.values((rowIndex - 1), columnUpperbound); this.values(0, columnIndex) = this.values(0, (columnIndex - 1)); this.values(0, 0) = backup; Console.Write((this.values(rowIndex, columnIndex) + " ")); Console.WriteLine(); Console.WriteLine(); Console.ReadLine(); } } public class Exercise2Solution { void Main() { Console.WriteLine("Row Count ?"); int rowCount = Console.ReadLine(); Console.WriteLine("Column Count ?"); int columnCount = Console.ReadLine(); int upperboundFirstDimension = (rowCount - 1); int upperboundSecondDimension = (columnCount - 1); int[] matrix = new int[0]; Console.WriteLine("Start Value ?"); int startValue = Console.ReadLine(); Console.WriteLine(); int rowIndex; int columnIndex; int value; value = startValue; this.matrix(rowIndex, columnIndex) = value; this.value += new System.EventHandler(1); Console.Write((this.matrix(rowIndex, columnIndex) + " ")); Console.WriteLine(); Console.WriteLine(); int backup = upperboundFirstDimension; upperboundFirstDimension = upperboundSecondDimension; upperboundSecondDimension = backup; int[] transpone = new int[0]; this.transpone(rowIndex, columnIndex) = this.matrix(columnIndex, rowIndex); Console.Write((this.transpone(rowIndex, columnIndex) + " ")); Console.WriteLine(); Console.ReadLine(); } } //Bezoek www.vbvoorbeelden.be voor meer C# voorbeelden. //Copyright - De Wolf / vbvoorbeelden - 2003-2011 - Alle rechten voorbehouden.