Results 1 to 4 of 4

Thread: Are Jagged arrays supported in Csharp?

  1. #1
    Join Date
    Sep 2009
    Posts
    125

    Are Jagged arrays supported in Csharp?

    I have a question related to Jagged Arrays in Csharp. I have studied C and C++. I knw that C and C++ only support orthogonal arrays. But when I studied Java I learnt that Java also includes a special type of array called Jagged arrays. Are these arrays also supported in Csharp as Csharp and Java have many things common between them. What Jagged Arrays in Csharp?

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Are Jagged arrays supported in Csharp?

    To explain it to you in simple terms, Jagged arrays are also known as 'Arrays of Arrays'. It is allowed for a Jagged Array to have elements with variable dimensions and sizes. Just like Java, Csharp also supporst Jagged Arrays as it is not a compulsion for arrays to be orthogonal. Csharp also supports the traditional orthogonal arrays.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Are Jagged arrays supported in Csharp?

    Yes, C# also supports Jagged Arrays. Arrays in Csharp are all considered to be only single-dimensional arrays. Thus, this principle allows C# to support Jagged Arrays. Jagged Arras are that unique arrays of which the rows and columns need not be of static length.
    eg.

    Code:
        int[][] Jarray = new int[][] 
    {
        new int[] {1,2,3,4,5,6,7},
        new int[] {5,10,15},
        new int[] {1,10,30,40}
    };

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Are Jagged arrays supported in Csharp?

    I had not even studied Java or any other programming languages earlier and I was directly learning C#. Even I was completely confused about the Concept of Jagged Array. Csharp does includes Jagged Array in addition to orthogonal arrays.
    eg.

    Code:
    using System;
    
    class Jagged
    {
        static void Main()
        {
            int[][] arr = new int[3][];
    
            arr[0] = new int[3];
            arr[0][0] = 10;
            arr[0][1] = 20;
            arr[0][2] = 30;
    
            arr[1] = new int[1];
    
            arr[2] = new int[2] { 2,4};
    
               for (int i = 0; i < arr.Length; i++)
            {
                int[] aarj = arr[i];
                for (int j = 0; j < arrj.Length; j++)
                {
                    Console.Write(arrj[a] + " ");
                }
                Console.WriteLine();
            }
        }
    }

Similar Threads

  1. Replies: 5
    Last Post: 04-02-2012, 10:44 AM
  2. Replies: 3
    Last Post: 04-02-2012, 09:57 AM
  3. Exception Handling in Csharp
    By Jesus2 in forum Software Development
    Replies: 3
    Last Post: 11-11-2009, 11:22 PM
  4. What do you mean by Csharp Delegates?
    By Jarini in forum Software Development
    Replies: 3
    Last Post: 11-11-2009, 09:57 PM
  5. Create a class in C # (CSharp)
    By Aadi in forum Guides & Tutorials
    Replies: 2
    Last Post: 10-12-2008, 12:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,017,157.57617 seconds with 16 queries