<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FCollections_Data_Structure%2FArray_Dimension</id>
		<title>Csharp/C Sharp/Collections Data Structure/Array Dimension - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FCollections_Data_Structure%2FArray_Dimension"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Collections_Data_Structure/Array_Dimension&amp;action=history"/>
		<updated>2026-04-30T00:11:53Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Collections_Data_Structure/Array_Dimension&amp;diff=640&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Collections_Data_Structure/Array_Dimension&amp;diff=640&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Collections_Data_Structure/Array_Dimension&amp;diff=641&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Collections_Data_Structure/Array_Dimension&amp;diff=641&amp;oldid=prev"/>
				<updated>2010-05-26T11:39:18Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Call GetLength for two dimenional array==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
class ChessBoard {&lt;br /&gt;
    static void Main(String[] args) {&lt;br /&gt;
        Char[,] SquareColor = new Char[8, 8];&lt;br /&gt;
        for (int i = 0; i &amp;lt; SquareColor.GetLength(0); i++) {&lt;br /&gt;
            for (int x = 0; x &amp;lt; SquareColor.GetLength(1); x++) {&lt;br /&gt;
                if ((x % 2) == 0)&lt;br /&gt;
                    if ((i % 2) == 0)&lt;br /&gt;
                        SquareColor[i, x] = &amp;quot;W&amp;quot;;&lt;br /&gt;
                    else&lt;br /&gt;
                        SquareColor[i, x] = &amp;quot;B&amp;quot;;&lt;br /&gt;
                else&lt;br /&gt;
                    if ((i % 2) == 0)&lt;br /&gt;
                        SquareColor[i, x] = &amp;quot;B&amp;quot;;&lt;br /&gt;
                    else&lt;br /&gt;
                        SquareColor[i, x] = &amp;quot;W&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        for (int i = 0; i &amp;lt; SquareColor.GetLength(0); i++) {&lt;br /&gt;
            for (int x = 0; x &amp;lt; SquareColor.GetLength(1); x++) {&lt;br /&gt;
                Console.Write(SquareColor[i, x]);&lt;br /&gt;
            }&lt;br /&gt;
            Console.WriteLine();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Catch IndexOutOfRangeException Exception==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
   &lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        try&lt;br /&gt;
        {&lt;br /&gt;
            int [] IntegerArray = new int [5];&lt;br /&gt;
   &lt;br /&gt;
            IntegerArray[10] = 123;&lt;br /&gt;
        }&lt;br /&gt;
        catch(IndexOutOfRangeException)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;An invalid element index access was attempted.&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Catch OutOfMemoryException ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
   &lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int [] LargeArray;&lt;br /&gt;
   &lt;br /&gt;
        try&lt;br /&gt;
        {&lt;br /&gt;
            LargeArray = new int [2000000000];&lt;br /&gt;
        }&lt;br /&gt;
        catch(OutOfMemoryException)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;The CLR is out of memory.&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Demonstrate a two-dimensional array==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
// Demonstrate a two-dimensional array.  &lt;br /&gt;
using System; &lt;br /&gt;
public class TwoD {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    int t, i; &lt;br /&gt;
    int[,] table = new int[3, 4];  &lt;br /&gt;
  &lt;br /&gt;
    for( t = 0; t &amp;lt; 3; ++t) {  &lt;br /&gt;
      for(i = 0; i &amp;lt; 4; ++i) {  &lt;br /&gt;
        table[t,i] = (t*4)+i+1;  &lt;br /&gt;
        Console.Write(table[t,i] + &amp;quot; &amp;quot;);  &lt;br /&gt;
      }  &lt;br /&gt;
      Console.WriteLine(); &lt;br /&gt;
    }  &lt;br /&gt;
  } &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Demonstrate jagged arrays==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
// Demonstrate jagged arrays. &lt;br /&gt;
using System; &lt;br /&gt;
 &lt;br /&gt;
public class Jagged1 {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    int[][] jagged = new int[3][];  &lt;br /&gt;
    jagged[0] = new int[4];  &lt;br /&gt;
    jagged[1] = new int[3];  &lt;br /&gt;
    jagged[2] = new int[5];  &lt;br /&gt;
  &lt;br /&gt;
    int i; &lt;br /&gt;
 &lt;br /&gt;
    // store values in first array &lt;br /&gt;
    for(i=0; i &amp;lt; 4; i++)   &lt;br /&gt;
      jagged[0][i] = i;  &lt;br /&gt;
 &lt;br /&gt;
    // store values in second array &lt;br /&gt;
    for(i=0; i &amp;lt; 3; i++)   &lt;br /&gt;
      jagged[1][i] = i;  &lt;br /&gt;
 &lt;br /&gt;
    // store values in third array &lt;br /&gt;
    for(i=0; i &amp;lt; 5; i++)   &lt;br /&gt;
      jagged[2][i] = i;  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    // display values in first array &lt;br /&gt;
    for(i=0; i &amp;lt; 4; i++)   &lt;br /&gt;
      Console.Write(jagged[0][i] + &amp;quot; &amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    // display values in second array &lt;br /&gt;
    for(i=0; i &amp;lt; 3; i++)   &lt;br /&gt;
      Console.Write(jagged[1][i] + &amp;quot; &amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    // display values in third array &lt;br /&gt;
    for(i=0; i &amp;lt; 5; i++)   &lt;br /&gt;
      Console.Write(jagged[2][i] + &amp;quot; &amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Demonstrate Length with jagged arrays==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
// Demonstrate Length with jagged arrays. &lt;br /&gt;
 &lt;br /&gt;
using System; &lt;br /&gt;
 &lt;br /&gt;
public class Jagged {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    int[][] network_nodes = new int[4][];  &lt;br /&gt;
    network_nodes[0] = new int[3];  &lt;br /&gt;
    network_nodes[1] = new int[7];  &lt;br /&gt;
    network_nodes[2] = new int[2];  &lt;br /&gt;
    network_nodes[3] = new int[5];  &lt;br /&gt;
 &lt;br /&gt;
  &lt;br /&gt;
    int i, j; &lt;br /&gt;
 &lt;br /&gt;
    // fabricate some fake CPU usage data    &lt;br /&gt;
    for(i=0; i &amp;lt; network_nodes.Length; i++)   &lt;br /&gt;
      for(j=0; j &amp;lt; network_nodes[i].Length; j++)  &lt;br /&gt;
        network_nodes[i][j] = i * j + 70;  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Total number of network nodes: &amp;quot; + network_nodes.Length + &amp;quot;\n&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    for(i=0; i &amp;lt; network_nodes.Length; i++) {  &lt;br /&gt;
      for(j=0; j &amp;lt; network_nodes[i].Length; j++) { &lt;br /&gt;
        Console.Write(&amp;quot;CPU usage at node &amp;quot; + i +  &lt;br /&gt;
                      &amp;quot; CPU &amp;quot; + j + &amp;quot;: &amp;quot;); &lt;br /&gt;
        Console.Write(network_nodes[i][j] + &amp;quot;% &amp;quot;);  &lt;br /&gt;
        Console.WriteLine();  &lt;br /&gt;
      } &lt;br /&gt;
      Console.WriteLine();  &lt;br /&gt;
    } &lt;br /&gt;
 &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==illustrates the use of a two-dimensional rectangular array==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
  illustrates the use of a two-dimensional rectangular array&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
public class Example10_6 {&lt;br /&gt;
  public static void Main()  {&lt;br /&gt;
    const int rows = 8;&lt;br /&gt;
    const int columns = 8;&lt;br /&gt;
    string[,] chessboard = new string[rows, columns];&lt;br /&gt;
    chessboard[0, 0] = &amp;quot;White Rook&amp;quot;;&lt;br /&gt;
    chessboard[1, 0] = &amp;quot;White Pawn&amp;quot;;&lt;br /&gt;
    chessboard[2, 3] = &amp;quot;White King&amp;quot;;&lt;br /&gt;
    chessboard[3, 5] = &amp;quot;Black Bishop&amp;quot;;&lt;br /&gt;
    chessboard[4, 4] = &amp;quot;Black Pawn&amp;quot;;&lt;br /&gt;
    chessboard[5, 3] = &amp;quot;Black King&amp;quot;;&lt;br /&gt;
    for (int row = 0; row &amp;lt; rows; row++)&lt;br /&gt;
    {&lt;br /&gt;
      for (int column = 0; column &amp;lt; columns; column++)&lt;br /&gt;
      {&lt;br /&gt;
        Console.WriteLine(&amp;quot;chessboard[&amp;quot; + row + &amp;quot;, &amp;quot; + column + &amp;quot;] = &amp;quot; +&lt;br /&gt;
          chessboard[row, column]);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Initialize a two-dimensional array==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
// Initialize a two-dimensional array. &lt;br /&gt;
 &lt;br /&gt;
using System; &lt;br /&gt;
 &lt;br /&gt;
public class Squares {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    int[,] sqrs = { &lt;br /&gt;
      { 1, 1 }, &lt;br /&gt;
      { 2, 4 }, &lt;br /&gt;
      { 3, 9 }, &lt;br /&gt;
      { 4, 16 }, &lt;br /&gt;
      { 5, 25 }, &lt;br /&gt;
      { 6, 36 }, &lt;br /&gt;
      { 7, 49 }, &lt;br /&gt;
      { 8, 64 }, &lt;br /&gt;
      { 9, 81 }, &lt;br /&gt;
      { 10, 100 } &lt;br /&gt;
    }; &lt;br /&gt;
    int i, j; &lt;br /&gt;
 &lt;br /&gt;
    for( i = 0; i &amp;lt; 10; i++) {  &lt;br /&gt;
      for(j = 0; j &amp;lt; 2; j++)  &lt;br /&gt;
        Console.Write(sqrs[i,j] + &amp;quot; &amp;quot;);   &lt;br /&gt;
      Console.WriteLine();  &lt;br /&gt;
    }  &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==initialize a two-dimensional rectangular array, and use the array properties and methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example10_7.cs illustrates how to initialize&lt;br /&gt;
  a two-dimensional rectangular array, and use the&lt;br /&gt;
  array properties and methods&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
public class Example10_7&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    // create and initialize the names array&lt;br /&gt;
    string[,] names =&lt;br /&gt;
    {&lt;br /&gt;
      {&amp;quot;Jason&amp;quot;, &amp;quot;Marcus&amp;quot;, &amp;quot;Price&amp;quot;},&lt;br /&gt;
      {&amp;quot;Steve&amp;quot;, &amp;quot;Edward&amp;quot;, &amp;quot;Smith&amp;quot;},&lt;br /&gt;
      {&amp;quot;Cynthia&amp;quot;, &amp;quot;Ann&amp;quot;, &amp;quot;Williams&amp;quot;},&lt;br /&gt;
      {&amp;quot;Gail&amp;quot;, &amp;quot;Patricia&amp;quot;, &amp;quot;Jones&amp;quot;},&lt;br /&gt;
    };&lt;br /&gt;
    // display the Rank and Length properties of the names array&lt;br /&gt;
    Console.WriteLine(&amp;quot;names.Rank (number of dimensions) = &amp;quot; + names.Rank);&lt;br /&gt;
    Console.WriteLine(&amp;quot;names.Length (number of elements) = &amp;quot; + names.Length);&lt;br /&gt;
    // use the GetLength() method to get number of elements&lt;br /&gt;
    // in each dimension of the names array&lt;br /&gt;
    int numberOfRows = names.GetLength(0);&lt;br /&gt;
    int numberOfColumns = names.GetLength(1);&lt;br /&gt;
    Console.WriteLine(&amp;quot;Number of rows = &amp;quot; + numberOfRows);&lt;br /&gt;
    Console.WriteLine(&amp;quot;Number of columns = &amp;quot; + numberOfColumns);&lt;br /&gt;
    // display the elements of the names array&lt;br /&gt;
    for (int row = 0; row &amp;lt; numberOfRows; row++)&lt;br /&gt;
    {&lt;br /&gt;
      for (int column = 0; column &amp;lt; numberOfColumns; column++)&lt;br /&gt;
      {&lt;br /&gt;
        Console.WriteLine(&amp;quot;names[&amp;quot; + row + &amp;quot;, &amp;quot; + column + &amp;quot;] = &amp;quot; +&lt;br /&gt;
          names[row, column]);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Multidimensional and Jagged Arrays:Jagged Arrays==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
// &lt;br /&gt;
using System;&lt;br /&gt;
public class JaggedArrays {&lt;br /&gt;
    &lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int[][] matrix = {new int[5], new int[4], new int[2] };&lt;br /&gt;
        matrix[0][3] = 4;&lt;br /&gt;
        matrix[1][1] = 8;&lt;br /&gt;
        matrix[2][0] = 5;&lt;br /&gt;
        &lt;br /&gt;
        for (int i = 0; i &amp;lt; matrix.Length; i++)&lt;br /&gt;
        {&lt;br /&gt;
            for (int j = 0; j &amp;lt; matrix[i].Length; j++)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(&amp;quot;matrix[{0}, {1}] = {2}&amp;quot;, i, j, matrix[i][j]);&lt;br /&gt;
            }&lt;br /&gt;
        }       &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Multi dimensional Arrays 1==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
public class MultidimensionalArrays&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int[,] matrix = { {1, 1}, {2, 2}, {3, 5}, {4, 5}, {134, 44} };&lt;br /&gt;
        &lt;br /&gt;
        for (int i = 0; i &amp;lt; matrix.GetLength(0); i++)&lt;br /&gt;
        {&lt;br /&gt;
            for (int j = 0; j &amp;lt; matrix.GetLength(1); j++)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(&amp;quot;matrix[{0}, {1}] = {2}&amp;quot;, i, j, matrix[i, j]);&lt;br /&gt;
            }&lt;br /&gt;
        }       &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sum the values on a diagonal of a atrix==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
// Sum the values on a diagonal of a 3x3x3 matrix. &lt;br /&gt;
using System; &lt;br /&gt;
 &lt;br /&gt;
public class ThreeDMatrix {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    int[,,] m = new int[3, 3, 3]; &lt;br /&gt;
    int sum = 0; &lt;br /&gt;
    int n = 1; &lt;br /&gt;
 &lt;br /&gt;
    for(int x=0; x &amp;lt; 3; x++) {&lt;br /&gt;
      for(int y=0; y &amp;lt; 3; y++) {&lt;br /&gt;
        for(int z=0; z &amp;lt; 3; z++) { &lt;br /&gt;
          m[x, y, z] = n++; &lt;br /&gt;
        }  &lt;br /&gt;
      }  &lt;br /&gt;
    }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    sum = m[0,0,0] + m[1,1,1] + m[2, 2, 2]; &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Sum of first diagonal: &amp;quot; + sum); &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==the use of a jagged array==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example10_9.cs illustrates the use of a jagged array&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
public class Example10_9&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    // declare a jagged array of four rows,&lt;br /&gt;
    // with each row consisting of a string array&lt;br /&gt;
    string[][] names = new string[4][];&lt;br /&gt;
    // the first row is an array of three strings&lt;br /&gt;
    names[0] = new string[3];&lt;br /&gt;
    names[0][0] = &amp;quot;Jason&amp;quot;;&lt;br /&gt;
    names[0][1] = &amp;quot;Marcus&amp;quot;;&lt;br /&gt;
    names[0][2] = &amp;quot;Price&amp;quot;;&lt;br /&gt;
    // the second row is an array of two strings&lt;br /&gt;
    names[1] = new string[2];&lt;br /&gt;
    names[1][0] = &amp;quot;Steve&amp;quot;;&lt;br /&gt;
    names[1][1] = &amp;quot;Smith&amp;quot;;&lt;br /&gt;
    // the third row is an array of four strings&lt;br /&gt;
    names[2] = new string[] {&amp;quot;Cynthia&amp;quot;, &amp;quot;Ann&amp;quot;, &amp;quot;Jane&amp;quot;, &amp;quot;Williams&amp;quot;};&lt;br /&gt;
    names[3] = new string[] {&amp;quot;Gail&amp;quot;, &amp;quot;Jones&amp;quot;};&lt;br /&gt;
    // display the Rank and Length properties for the names array&lt;br /&gt;
    Console.WriteLine(&amp;quot;names.Rank = &amp;quot; + names.Rank);&lt;br /&gt;
    Console.WriteLine(&amp;quot;names.Length = &amp;quot; + names.Length);&lt;br /&gt;
    // display the Rank and Length properties for the arrays&lt;br /&gt;
    // in each row of the names array&lt;br /&gt;
    for (int row = 0; row &amp;lt; names.Length; row++)&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(&amp;quot;names[&amp;quot; + row + &amp;quot;].Rank = &amp;quot; + names[row].Rank);&lt;br /&gt;
      Console.WriteLine(&amp;quot;names[&amp;quot; + row + &amp;quot;].Length = &amp;quot; + names[row].Length);&lt;br /&gt;
    }&lt;br /&gt;
    // display the array elements for each row in the names array&lt;br /&gt;
    for (int row = 0; row &amp;lt; names.Length; row++)&lt;br /&gt;
    {&lt;br /&gt;
      for (int element = 0; element &amp;lt; names[row].Length; element++)&lt;br /&gt;
      {&lt;br /&gt;
        Console.WriteLine(&amp;quot;names[&amp;quot; + row + &amp;quot;][&amp;quot; + element + &amp;quot;] = &amp;quot; +&lt;br /&gt;
          names[row][element]);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==the use of a three-dimensional rectangular array==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example10_8.cs illustrates the use of&lt;br /&gt;
  a three-dimensional rectangular array&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
public class Example10_8&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    // create the galaxy array&lt;br /&gt;
    int[,,] galaxy = new int [10, 5, 3];&lt;br /&gt;
    // set two galaxy array elements to the star&amp;quot;s brightness&lt;br /&gt;
    galaxy[1, 3, 2] = 3;&lt;br /&gt;
    galaxy[4, 1, 2] = 9;&lt;br /&gt;
    // display the Rank and Length properties of the galaxy array&lt;br /&gt;
    Console.WriteLine(&amp;quot;galaxy.Rank (number of dimensions) = &amp;quot; + galaxy.Rank);&lt;br /&gt;
    Console.WriteLine(&amp;quot;galaxy.Length (number of elements) = &amp;quot; + galaxy.Length);&lt;br /&gt;
    // display the galaxy array elements, but only display elements that&lt;br /&gt;
    // have actually been set to a value (or &amp;quot;contain stars&amp;quot;)&lt;br /&gt;
    for (int x = 0; x &amp;lt; galaxy.GetLength(0); x++)&lt;br /&gt;
    {&lt;br /&gt;
      for (int y = 0; y &amp;lt; galaxy.GetLength(1); y++)&lt;br /&gt;
      {&lt;br /&gt;
        for (int z = 0; z &amp;lt; galaxy.GetLength(2); z++)&lt;br /&gt;
        {&lt;br /&gt;
          if (galaxy[x, y, z] != 0)&lt;br /&gt;
          {&lt;br /&gt;
            Console.WriteLine(&amp;quot;galaxy[&amp;quot; + x + &amp;quot;, &amp;quot; + y + &amp;quot;, &amp;quot; + z +&amp;quot;] = &amp;quot; +&lt;br /&gt;
              galaxy[x, y, z]);&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Uses a jagged array to store sales figures==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// Sales.cs -- Uses a jagged array to store sales figures, then writes report&lt;br /&gt;
//             for one month. Demonstrates that you do not have to worry about&lt;br /&gt;
//             looking for empty elements.&lt;br /&gt;
//&lt;br /&gt;
//             Compile this program with the following command line:&lt;br /&gt;
//                 C:&amp;gt;csc Sales.cs&lt;br /&gt;
//&lt;br /&gt;
namespace nsSales&lt;br /&gt;
{&lt;br /&gt;
    using System;&lt;br /&gt;
    &lt;br /&gt;
    public class Sales&lt;br /&gt;
    {&lt;br /&gt;
        static public void Main ()&lt;br /&gt;
        {&lt;br /&gt;
             DateTime now = DateTime.Now;&lt;br /&gt;
             Random rand = new Random ((int) now.Millisecond);&lt;br /&gt;
             int [] MonthLen = new int []&lt;br /&gt;
                           {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};&lt;br /&gt;
             double [][] Sales2000 = new double [12][];&lt;br /&gt;
             for (int x = 0; x &amp;lt; MonthLen.Length; ++x)&lt;br /&gt;
             {&lt;br /&gt;
                 Sales2000[x] = new double [MonthLen[x]];&lt;br /&gt;
                 for (int y = 0; y &amp;lt; Sales2000[x].Length; ++y)&lt;br /&gt;
                 {&lt;br /&gt;
                     Sales2000[x][y] = rand.NextDouble() * 100;// % 11 + 20;&lt;br /&gt;
                 }&lt;br /&gt;
             }&lt;br /&gt;
             Console.Write (&amp;quot;February Sales Report (in thousands):&amp;quot;);&lt;br /&gt;
             for (int x = 0; x &amp;lt; Sales2000[1].Length; ++x)&lt;br /&gt;
             {&lt;br /&gt;
                  if ((x % 4) == 0)&lt;br /&gt;
                      Console.WriteLine ();&lt;br /&gt;
                  Console.Write (&amp;quot;    Feb. {0,-2:D}: {1,-4:F1}&amp;quot;, x + 1, Sales2000[1][x]);&lt;br /&gt;
             }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Uses a two-dimensional array to store grades for students==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// Grades.cs -- Uses a two-dimensional array to store grades for students&lt;br /&gt;
//&lt;br /&gt;
//              Compile this program with the following command line:&lt;br /&gt;
//                  C:&amp;gt;csc Grades.cs&lt;br /&gt;
namespace nsGrades&lt;br /&gt;
{&lt;br /&gt;
    using System;&lt;br /&gt;
    &lt;br /&gt;
    public class Grades&lt;br /&gt;
    {&lt;br /&gt;
        static public void Main ()&lt;br /&gt;
        {&lt;br /&gt;
             DateTime now = DateTime.Now;&lt;br /&gt;
             Random rand = new Random ((int) now.Millisecond);&lt;br /&gt;
             int [,] Grades = new int [5,10];&lt;br /&gt;
             for (int x = 0; x &amp;lt; Grades.GetLength (0); ++x)&lt;br /&gt;
             {&lt;br /&gt;
                 for (int y = 0; y &amp;lt; Grades.GetLength(1); ++y)&lt;br /&gt;
                 {&lt;br /&gt;
                     Grades [x, y] = 70 + rand.Next () % 31;&lt;br /&gt;
                 }&lt;br /&gt;
             }&lt;br /&gt;
             int [] Average = new int [10];&lt;br /&gt;
             Console.WriteLine (&amp;quot;Grade summary:\r\n&amp;quot;);&lt;br /&gt;
             Console.WriteLine (&amp;quot;Student   1   2   3   4   5   6   7   8   9  10&amp;quot;);&lt;br /&gt;
             Console.WriteLine (&amp;quot;        ----------------------------------------&amp;quot;);&lt;br /&gt;
             for (int x = 0; x &amp;lt; Grades.GetLength (0); ++x)&lt;br /&gt;
             {&lt;br /&gt;
                 Console.Write (&amp;quot;Test &amp;quot; + (x + 1) + &amp;quot; &amp;quot;);&lt;br /&gt;
                 for (int y = 0; y &amp;lt; Grades.GetLength(1); ++y)&lt;br /&gt;
                 {&lt;br /&gt;
                     Average[y] += Grades[x,y];&lt;br /&gt;
                     Console.Write (&amp;quot;{0,4:D}&amp;quot;, Grades[x,y]);&lt;br /&gt;
                 }&lt;br /&gt;
                 Console.WriteLine ();&lt;br /&gt;
             }&lt;br /&gt;
             Console.Write (&amp;quot;\r\n Avg.  &amp;quot;);&lt;br /&gt;
             foreach (int Avg in Average)&lt;br /&gt;
             {&lt;br /&gt;
                 Console.Write (&amp;quot;{0,4:D}&amp;quot;, Avg / Grades.GetLength(0));&lt;br /&gt;
             }&lt;br /&gt;
             Console.WriteLine ();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Use the Length array property on a 3-D array==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
// Use the Length array property on a 3-D array. &lt;br /&gt;
 &lt;br /&gt;
using System; &lt;br /&gt;
 &lt;br /&gt;
public class LengthDemo3D {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    int[,,] nums = new int[10, 5, 6];  &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Length of nums is &amp;quot; + nums.Length);  &lt;br /&gt;
  &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>