HomeCSharpC# Error CS1023 – Embedded statement cannot be a declaration or labeled statement

C# Error CS1023 – Embedded statement cannot be a declaration or labeled statement

C# Error

CS1023 – Embedded statement cannot be a declaration or labeled statement

Reason for the Error & Solution

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  
   }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...