Edit

Share via


Compiler Error CS1023

Embedded statement cannot be a declaration or labeled statement

An embedded statement, such as the statements following an if statement, can contain neither declarations nor labeled statements.

The following sample generates CS1023 twice:

// CS1023.cs  
public class a  
{  
   public static void Main()  
   {  
      if (1)  
         int i;      // CS1023, declaration is not valid here  
  
      if (1)  
         xx : i++;   // CS1023, labeled statement is not valid here  
   }  
}