Compiler Error CS1933
Expression cannot contain query expressions
Some variables cannot be initialized with a query expression. Constants cannot be initialized with query expressions because constants may only be initialized with some combination of literals, named constants, and mathematical operators.
To correct this error
- Remove the modifier from the query variable.
Example
The following example generates CS1933:
// cs1933.cs
using System.Linq;
using System.Collections;
class Program
{
const IEnumerable e = from x in new[] { 1, 2, 3 } select x; // CS1933
static int Main()
{
return 1;
}
}
Note
This compiler error is no longer used in Roslyn. The previous example generates CS0133 when compiled with Roslyn.
See also
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.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for