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 884737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:47:41+00:00 2026-05-15T12:47:41+00:00

I thought this was straight forward, but given a multi-dimensional array string[,] table =

  • 0

I thought this was straight forward, but given a multi-dimensional array

        string[,] table = new string[,] 
        {
            {"Apple", "Banana", "Clementine", "Damson"},
            {"Elderberry", "Fig", "Grape", "Huckleberry"},
            {"Indian Prune", "Jujube", "Kiwi", "Lime"}
        };

How can I return a specific array using an index?

I tried the following but it does not work.

string[] firstArray = table[0];

Thank you.

  • 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-15T12:47:42+00:00Added an answer on May 15, 2026 at 12:47 pm

    Forr you the best approach is an extension method on array.Then you can invoke it in everywhere.
    see below.Since you may have many such arrays in your project once you implement an extension method you can apply to any array as table.method(row)

     public static class ext{
                public static string[] twodim(this string[,] inarr, int row) {
                    string[] ret = new string[inarr.GetLength(1)];
                    for (int i = 0; i < inarr.GetLength(1); i++)
                        ret[i] = inarr[row, i];
                    return ret;
                }
            }
     public class Program{
           static void dump(string name, string[] arr){
               Console.WriteLine(name);
               for (int i = 0; i < arr.Length; i++)
                   Console.WriteLine("  {0}  ", arr[i]);
           }
      static void Main(string[] args){
         string[,] table = new string[,] {
                {"Apple", "Banana", "Clementine", "Damson"},
                {"Elderberry", "Fig", "Grape", "Huckleberry"},
                {"Indian Prune", "Jujube", "Kiwi", "Lime"}
            };
    
         dump("Row 0", table.twodim(0));
        dump("Row 0", table.twodim(1));
    dump("Row 0", table.twodim(2));
    
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer My favorite way is : <?php $var = array( 'prop1'… May 16, 2026 at 4:26 pm
  • Editorial Team
    Editorial Team added an answer You are sharing state between threads (i.e., in is_all_wait) without… May 16, 2026 at 4:26 pm
  • Editorial Team
    Editorial Team added an answer I would recommend ASIHTTPRequest. http://allseeing-i.com/ASIHTTPRequest/ May 16, 2026 at 4:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a multidimensional numpy array, and I need to iterate across a given
I have been trying to wrap my head around this for a while now
As I was writing a for loop earlier today, I thought that there must
I want to use one data source (e.g. an Array) for multiple Datagrids that
Firs off all, I'm not sure if there will be any simple and straight
I'm having trouble implementing a virtual D-pad in an EAGLView (OpenGL ES). I thought
Preface: I was thinking the other day about a new database structure for a
I'm using Ubuntu 10, python 2.6.5 I'm following this tutorial: http://www.djangobook.com/en/2.0/chapter02 I followed all
I frequently read that struct s should be immutable - aren't they by definition?
In my Google Maps application I can place markers on the map, and I

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.