日期:2014-05-18 浏览次数:21290 次
string[][] test_array = new string[4][] {
new string[]{"aaa","ddd","fff"},
new string[]{"bbb",null,"ggg"},
new string[]{null,null,"hhh"},
new string[]{"ccc","eee","iii"}
};
for (int k = 0; k < test_array.Count() - 1; k++)
{
for (int i = 0; i < test_array.FirstOrDefault().Count(); i++)
{
for (int j = test_array.Count() - 1; j > 0; j--)
{
if (string.IsNullOrEmpty(test_array[j][i]) && !string.IsNullOrEmpty(test_array[j - 1][i]))
{
string temp = test_array[j][i];
test_array[j][i] = test_array[j - 1][i];
test_array[j - 1][i] = temp;
}
}
}
}
for (int i = 0; i < test_array.Count(); i++)
{
for (int j = 0; j < test_array[i].Count(); j++)
{
Console.Write(test_array[i][j]+"\t");
}
Console.Write("\n");
}