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

Related Questions

I'm new to AutoFac, but I thought this would be pretty straight forward. I've
Thought this would be pretty straight forward, but my value is remaining the same
I thought this was pretty straight forward but I don't get the same results
So i thought this would be straight forward but i keep getting compile errors,
So I thought this script was pretty straight forward: <a id=BackButtonlnk href=# class=white onClick=history.go(-1)></a>
I had thought that this would be a relatively straight forward mapping / persistence
Maybe I'm losing my mind - I thought this was straight forward. ListCode.DataTextField =
This must be rather trivial and straight forward, but I cannot figure it out.
I have what I thought was a straight-forward query, but I cant seem to
I have, what I thought was a pretty straight-forward query. In normal Sql 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.