Compiler Error CS0742
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.
- Add a select clause or group clause to the query.
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.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: