Created
April 27, 2012 11:17
-
-
Save TryJSIL/2508480 to your computer and use it in GitHub Desktop.
Multidimensional Arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public static class Program { | |
public static void Main (string[] args) { | |
// [y, x], not [x, y]! | |
var a = new string[5, 10]; | |
var h = a.GetLength(0); | |
var w = a.GetLength(1); | |
for (var y = 0; y < h; y++) | |
for (var x = 0; x < w; x++) | |
a[y, x] = String.Format("x={0}, y={1}", x, y); | |
foreach (var s in a) | |
Console.WriteLine(s); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment