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.

asked May 6, 2011 at 6:54
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"};
answered May 6, 2011 at 6:58
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"};
answered May 6, 2011 at 6:58

Comments

1

LOOK AT THIS

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

and also look for jagged array

answered May 6, 2011 at 6:59

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}; 
answered May 6, 2011 at 6:59

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.