1

I need to create a multi dimensional array of strings in C# like-

tiger elephant pigeon lion ant peacock

I'm unable to create. It either flags an error or throws an exception at the run time. Please help me with it, by giving the correct syntax.

2
  • 1
    Please post your code so we can track better. Commented May 6, 2011 at 6:57
  • 1
    why don't you accept any ans? Commented May 6, 2011 at 9:52

4 Answers 4

1
string[] animals = new string[]{"tiger", "elephant", "pigeon", "lion", "ant", "peacock"};
Sign up to request clarification or add additional context in comments.

1 Comment

it is an array or strings not a multidimentional array for strings
1

Am not sure I understand the question, the above doesn't appear to be a multidimensional array.

Do you simply want somthing along the lines of the below?

string[] animals = {"tiger", "elephant"};

Comments

1

LOOK AT THIS

string[,] siblings = new string[2, 2] { {"Mike","Amy"}, {"Mary","Albert"} };

and also look for jagged array

Comments

0

Here is an example of how to create multi-dimensional string array and have it initialized:

string[] myStringArray = new string[] { tiger, elephant, pigeon, lion, ant, peacock}; 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.