Compiler Error CS0622
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Error CS0622 

Error Message

Can only use array initializer expressions to assign to array types. Try using a new expression instead.

Syntax that is appropriate to initialize an array was used in the declaration of a non-array.


The following sample generates CS0622:

// CS0622.cs
using System;

public class Test
    public static void Main ()
        Test t = { new Test() };   // CS0622
        // Try the following instead:
        // Test[] t = { new Test() };
© 2015 Microsoft