Mukesh wrote:
[...]
string [,] strDetails
foreach(string[] str in strDetails)
{
//Code comes here
}
I have studied that it is not possible to do like this. The maximum
we can do is extracting individual values in the array.
Well "strDetails" isn't an array of arrays; it's a single
two-dimensional array. So that's why you can't enumerate the "string[]"
instances in the "strDetails" array. There aren't any.
That said, there's nothing to stop you from iterating over a single
dimension of the two-dimensional array, and then within that iterating
over the other dimension for the purpose of building a new
single-dimensional array of strings.
Something like this:
string[,] strDetails;
for (int i = 0; i < strDetails.GetLength(0); i++)
{
string[] str = new string[strDetails.GetLength(1)];
for (int j = 0; j < str.Length; j++)
{
str[j] = strDetails[i, j];
}
// do something with str here
}
Pete