I want to know where is the location each data in the array, index number of the data and also the value. I try to use switch case but he problem keep popping up "Control cannot fall through from one case label ('case1:') to another". I think because I used switch case inside of another switch case block. Help me to know if it is possible to have switch case inside of another switch case. If it possible why my code is error? If No, Can you suggest me another way to give the output that i want. I am very pleasure to accept your comments and suggestion.
//Multi-dimensional Array
int i, c = 0;
string[,] custNames = new string[2, 2] { { "Bob", "Smith" }, { "Sally", "Marks" } };
Console.WriteLine(custNames.Length);
for (i = 0; i < custNames.Length; i++)
{
switch(i)
{
case 0:
switch (c)
{
case 0:
c = 0;
Console.WriteLine("Array {0} : Value : {1}", i,
custNames[i, c]);
continue;
case 1:
c = 1;
Console.WriteLine("Array {0} : Value : {1}", i,
custNames[i, c]);
continue;
default:
break;
}
case 1:
for (c = 0; c < custNames.Length; c++)
{
switch (c)
{
case 0:
Console.WriteLine("Array {0} : Value : {1}", i,
custNames[i, c]);
continue;
case 1:
Console.WriteLine("Array {0} : Value : {1}", i,
custNames[i, c]);
continue;
default:
break;
}
}
default:
break;
}
}