the use of a jagged array : Array Dimension « Collections Data Structure « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# Book
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Collections Data Structure » Array DimensionScreenshots 
the use of a jagged array
the use of a jagged array
 
/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/
/*
  Example10_9.cs illustrates the use of a jagged array
*/

using System;

public class Example10_9
{

  public static void Main()
  {

    // declare a jagged array of four rows,
    // with each row consisting of a string array
    string[][] names = new string[4][];

    // the first row is an array of three strings
    names[0new string[3];
    names[0][0"Jason";
    names[0][1"Marcus";
    names[0][2"Price";

    // the second row is an array of two strings
    names[1new string[2];
    names[1][0"Steve";
    names[1][1"Smith";

    // the third row is an array of four strings
    names[2new string[] {"Cynthia""Ann""Jane""Williams"};
    names[3new string[] {"Gail""Jones"};

    // display the Rank and Length properties for the names array
    Console.WriteLine("names.Rank = " + names.Rank);
    Console.WriteLine("names.Length = " + names.Length);

    // display the Rank and Length properties for the arrays
    // in each row of the names array
    for (int row = 0; row < names.Length; row++)
    {
      Console.WriteLine("names[" + row + "].Rank = " + names[row].Rank);
      Console.WriteLine("names[" + row + "].Length = " + names[row].Length);
    }

    // display the array elements for each row in the names array
    for (int row = 0; row < names.Length; row++)
    {
      for (int element = 0; element < names[row].Length; element++)
      {
        Console.WriteLine("names[" + row + "][" + element + "] = " +
          names[row][element]);
      }
    }

  }

}


           
         
  
Related examples in the same category
1.Demonstrate a two-dimensional arrayDemonstrate a two-dimensional array
2.Sum the values on a diagonal of a 3x3x3 matrixSum the values on a diagonal of a 3x3x3 matrix
3.Initialize a two-dimensional arrayInitialize a two-dimensional array
4.Demonstrate jagged arraysDemonstrate jagged arrays
5.Use the Length array property on a 3-D arrayUse the Length array property on a 3-D array
6.Call GetLength for two dimenional array
7.Demonstrate Length with jagged arraysDemonstrate Length with jagged arrays
8.illustrates the use of a two-dimensional rectangular arrayillustrates the use of a two-dimensional rectangular array
9.initialize a two-dimensional rectangular array, and use the array properties and methodsinitialize a two-dimensional rectangular array, and use the array properties and methods
10.the use of a three-dimensional rectangular arraythe use of a three-dimensional rectangular array
11.Uses a two-dimensional array to store grades for studentsUses a two-dimensional array to store grades for students
12.Uses a jagged array to store sales figuresUses a jagged array to store sales figures
13.Multidimensional and Jagged Arrays:Jagged ArraysMultidimensional and Jagged Arrays:Jagged Arrays
14.Multi dimensional Arrays 1Multi dimensional Arrays 1
15.Catch OutOfMemoryException
16.Catch IndexOutOfRangeException Exception
17.Defines a 2D Array
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.