C# Error CS1733 – Expected expression

C# Error

CS1733 – Expected expression

Reason for the Error & Solution

Expected expression.

This error is produced whenever the compiler is expecting an expression on the line where the error occurred. In the following example, the trailing comma in the initializer indicates to the compiler that another expression will follow.

To correct this error

  • Provide the missing expression.

  • Remove the tokens that are causing the compiler to expect an expression.

Example

The following example produces CS1733 because of the trailing comma:

// cs1733.cs  
using System.Collections.Generic;  
public class Test  
{  
    public static void Main()  
    {  
        List<int> list = new List<int>() {{ 1, 2, }};// CS1733  
    }
}  

Leave A Reply

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

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...