2017-02-27 84 views
1

當聲明鋸齒狀,多維,鋸齒狀,鋸齒狀數組並調用其方法時,該類型名稱中的方括號與我聲明的類型不匹配。看來方括號是相反的。c#鋸齒狀多維鋸齒陣列類型名稱顯示不正確

爲什麼?

觀察:

class Program 
{ 
    static void Main(string[] args) 
    { 
     //Declare and allocate a jagged, jagged, multidimensional, jagged array 
     int[][][,][] x = new int[10][][,][]; 

     // GetType outputs "Int32[][,][][]", why not "System.Int32[][][,][]" ? 
     Console.WriteLine(x.GetType().Name 
      ); 

     //text copied from above does not equal the type, this is this False, why? 
     Console.WriteLine(typeof(System.Int32[][,][][]).Equals(typeof(int[][][,][])) 
      ); 


     //Reversing jagged, multidimensional square brackets of x.GetType().Name results in True 
     Console.WriteLine(typeof(System.Int32[][][,][]).Equals(typeof(int[][][,][])) 
      );   
    } 
} 

下面是實施例的輸出:

的Int32 [] [] [] []

爲什麼GetType().Name不等於System.Int32[][][,][]

回答

1

沒關係,我找到了答案。

ECMA-334第19.1節,數組類型。 C#是相反的。