C#学习笔记:foreach遍历变长数组

对变长数组使用foreach循环时,通常都要嵌套循环,才能得到该数据。


static void Main(string[] args)
 {
    
int[][] newArarry={new int[] {1},
                       
new int[] {1,2},
                       
new int[] {1,2,3},
                       
new int[] {1,2,3,4},
                       
new int[] {1,3},
                       
new int[] {1,2,3,4,5},
                       
new int[] {2,3,4},
                       
new int[] {3,5}};

    
foreach(int[] newArarry1 in newArarry)
    {
       
foreach(int newArarry2 in newArarry1)
       {
          Console.Write(newArarry2);
       }          
    }

   Console.ReadKey();
posted @ 2009-10-13 14:47  Jason.z  阅读(527)  评论(0编辑  收藏  举报