C# Tutorials - Herong's Tutorial Examples - v3.32, by Herong Yang
Jagged Arrays
This section describes jagged arrays which contain arrays as elements.
A Jagged array is an array that contains arrays as elements. Here are some examples:
// JaggedArrays.cs
// Copyright (c) 2006 HerongYang.com. All Rights Reserved.
using System;
class JaggedArrays {
static void Main() {
int[] a1 = new int[9]; // array of int
int[,] a2 = new int[3,9]; // two dimensional array of int
int[][] j1 = new int[9][]; // array of array of int
int[][,] j2 = new int[9][,]; // array of two dimensional array
int[,][] j3 = new int[3,9][]; // two dimensional array of array
a1[5] = 5;
a2[1,5] = 15;
j1[0] = a1;
j2[0] = a2;
j3[0,0] = a1;
Console.WriteLine("a1[5] = {0}", a1[5]);
Console.WriteLine("a2[1,5] = {0}", a2[1,5]);
Console.WriteLine("j1[0][5] = {0}", j1[0][5]);
Console.WriteLine("j2[0][1,5] = {0}", j2[0][1,5]);
Console.WriteLine("j3[0,0][5] = {0}", j3[0,0][5]);
}
}
Output:
a1[5] = 5 a2[1,5] = 15 j1[0][5] = 5 j2[0][1,5] = 15 j3[0,0][5] = 5
Table of Contents
Logical Expressions and Conditional Statements
Simple Types Are "struct" Types
Visual C# 2010 Express Edition
C# Compiler and Intermediate Language
Compiling C# Source Code Files
MSBuild - Microsoft Build Engine
System.Diagnostics.FileVersionInfo Class
WPF - Windows Presentation Foundation