Compiler Error CS0178
TOC
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

Compiler Error CS0178 

Error Message

Invalid rank specifier: expected ',' or ']'

An array initialization was ill-formed. For example, when specifying the array dimensions, you can specify the following:

  • A number in brackets

  • Empty brackets

  • A comma enclosed in brackets

For more information, see Arrays (C# Programming Guide) and the C# specification (C# Language Specification) section on array initializers.

Example

The following sample generates CS0178.

// CS0178.cs
class MyClass
{
   public static void Main()
   {
      int a = new int[5][,][][5;   // CS0178
      int[,] b = new int[3,2];   // OK

      int[][] c = new int[10][];
      c[0] = new int[5][5];   // CS0178
      c[0] = new int[2];   // OK
      c[1] = new int[2]{1,2};   // OK
   }
}
Show:
© 2016 Microsoft