i am Using for each Loop to a Jagged String Array in order to display the Elements in it but it is not working and i have tried this code !
public class Program
{
public static void Main(string[] args)
{
string[][] str = new string[5][];
str[0] = new string[5];
str[1] = new string[10];
str[2] = new string[20];
str[3] = new string[50];
str[4] = new string[10];
//Now store data in the jagged array
str[0][0] = "Pune";
str[1][0] = "Kolkata";
str[2][0] = "Bangalore";
str[3][0] = "The pink city named Jaipur";
str[4][0] = "Hyderabad";
//Lastly, display the content of each of the string arrays inside the jagged array
foreach(string[] i in str)
Console.WriteLine(i.ToString());
Console.ReadKey();
}
}
I have used a foreach loop but it is Printing
System.String[]
System.String[]
System.String[]
System.String[]
System.String[]
as output .... So get me the Problem Solution Please as what i have to modify to get the Display as
Pune
Kolkata
Bangalore
The pink city named Jaipur
Hyderabad
Console.WriteLine(i[0].ToString());