Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0742

Visual Studio 2008

A query body must end with a select clause or a group clause

A query expression must terminate with either a select clause or a group clause without a continuation.

To correct this error

The following code generates CS0742:

// cs0742.cs
using System.Linq;
public class Test
{
    public static int Main()
    {
        int[] array = { 1, 2, 3 };
        var query = from num in array; // CS0742
        return 1;
    }
}

If the group clause uses the into keyword to store the results of the grouping into a temporary identifier, it cannot be the last clause in a query. A select or second group clause is still required.

Community Additions

ADD
Show:
© 2015 Microsoft