multi dimensional string array in C#
I need to create a multi dimensional array of strings in C# like-
tiger elephant pigeon lion ant peacock
I'm unable to create. 开发者_StackOverflowIt either flags an error or throws an exception at the run time. Please help me with it, by giving the correct syntax.
string[] animals = new string[]{"tiger", "elephant", "pigeon", "lion", "ant", "peacock"};
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"};
LOOK AT THIS
string[,] siblings = new string[2, 2] { {"Mike","Amy"}, {"Mary","Albert"} };
and also look for jagged array
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};
精彩评论