Skip to content

Instantly share code, notes, and snippets.

@binki
Last active March 27, 2019 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binki/f108ad6f5ec2c48d6e7ffef578fa5b8f to your computer and use it in GitHub Desktop.
Save binki/f108ad6f5ec2c48d6e7ffef578fa5b8f to your computer and use it in GitHub Desktop.
MultiDimensionalArray
using System;
namespace MultiDimensionArray
{
class Program
{
static void Main(string[] args)
{
var x = new int[2, 3];
UseArray(x);
}
static void UseArray(int[,] x)
{
Console.WriteLine(x.GetLength(1)); // 3
Console.WriteLine(x[x.GetLength(0) - 1, x.GetLength(1) - 1]); // 0
{
var index0 = 0;
var index1 = x.GetLength(1) - 1;
x[index0, index1] = 2;
Console.WriteLine(x[index0, index1]); // 2
}
// 00
// 00
// 20
for(var index1 = 0; index1 < x.GetLength(1); index1++)
{
for(var index0 = 0; index0 < x.GetLength(0); index0++)
{
Console.Write(x[index0, index1]);
}
Console.WriteLine();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment