Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6770035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:15:51+00:00 2026-05-26T15:15:51+00:00

Using System, how can I dump the contents of a multidimensional array to the

  • 0

Using System, how can I dump the contents of a multidimensional array to the screen? I only require it for a 2-dimensional array that is being dynamically generated.

I’m creating my array using this method:

public static int[,] Alignment (int[] x, int[] y)
{

    // initiate matrix to be filled
    int[,] matrix = new int[x.Length,y.Length];

    // fill first row to zeros
    for (int i = 0; i < x.Length; i++)
    {
        matrix[i,0] = 0;
    }

    // fill first column to zeros
    for (int j = 0; j < y.Length; j++)
    {
        matrix[0,j] = 0;
    }

    DumpMultiDArray(matrix);
    return matrix;
}

and I’m trying to dump the array before returning it…

public static void DumpMultiDArray (int[,] MDArray)
{
    for (int i = 0; i < MDArray.GetLength(1); i++)
    // GetLength(1) can't seem to be found
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:15:52+00:00Added an answer on May 26, 2026 at 3:15 pm
    using System;
    
    namespace DumpMatrix
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                var matrix = new int[10, 15];
                var rand = new Random();
    
                for(int m=0; m<matrix.GetLength(0); ++m)
                {
                    for(int n=0; n<matrix.GetLength(1); ++n)
                    {
                        matrix[m, n] = rand.Next(100);
                    }
                }
    
                for (int m = 0; m < matrix.GetLength(0); ++m)
                {
                    for (int n = 0; n < matrix.GetLength(1); ++n)
                    {
                        Console.Write("{0,3} ", matrix[m, n]);
                    }
                    Console.WriteLine();
                }
    
                Console.ReadLine();
            }
        }
    }
    

    Outputs:

     59  94  90  99  74  42  86  11  91  36  77  47  33  64  82
      2  27   7  57  92  16  19  63  21   4  50  46  89  47  22
     40  22  16  87  30  53  50  79   6  66  59  27  54  73  29
     95  48   9  89   5  39  37  41  60   7  40  31  69  95  23
     95  96  63  68  96  55  31  46  34  28  52  47   1  90  32
     89  64  89  92   8   1  36   0  42  83   3  80  55  79  90
     22  80  84  82  71  62  63  85  77  73  64   2  75  60  52
     91  35  50  27  18  75  41  77  86  21  58  96  21  84  92
     74  75  66  44   6  71  63  19  19  70  25  78  12  18  44
     98  61  40  89  92  67  29  27  61  14  81   3  97  60  12
    

    In Visual Studio, you can click in the gutter and then run your program in debug mode:

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I send an email using SYstem.Net.Mail to an email address that is
I'm using System.Drawing.Color, is there anything in Visual Studio that can display the color
In Perl, you can execute system commands using system() or `` (backticks). You can
I can already do: using System.Windows.Forms; Button b; or: System.Windows.Forms.Button b; but I would
In C#, how many classes can you inherit from? When you write: using System.Web.UI;
Using the System.IO.Compression namespaces classes GZIPStream and DeflateStream I successfully can compress and decompress
what kind of 'unique' system identifiers can be easily obtained using C# (to hash
How can I generate types like these using the System.Reflection.Emit libraries: public class Test<T>
while using the appengine sdk i can't view the Output of my System.out.println statements
Can someone show me how to use the System.Numerics.BigInteger datatype? I tried using this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.