C# Error CS0743 – Expected contextual keyword ‘on’

C# Error

CS0743 – Expected contextual keyword ‘on’

Reason for the Error & Solution

Expected contextual keyword ‘on’

The pattern for a join clause is joininonequals, as shown in this example:

var query = from x in array1  
            join y in array2 on x equals y  
            select x;  

To correct this error

  1. Add the on keyword to the join clause.

Example

The following code generates CS0743:

// cs0743.cs  
using System;  
using System.Linq;  
  
public class C  
{  
    public static int Main()  
    {  
        int[] array1 = { 1, 2, 3, 4, 5, 6 };  
        int[] array2 = { 5, 6, 7, 8, 9 };  
        var c = from x in array1  
                join y in array2 x equals y // CS0743  
                select x;  
        return 1;  
    }  
}  

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