編譯器錯誤 CS1933
更新:2007 年 11 月
錯誤訊息
運算式不可以包含查詢運算式
部分變數無法使用查詢運算式進行初始化。因為常數只可以使用常值 (Literal)、具名常數和數學運算子的某些組合進行初始化,所以無法使用查詢運算式來初始化常數。
若要更正這個錯誤
- 移除查詢變數中的修飾詞。
範例
下列範例會產生 CS1933:
// cs1933.cs
using System.Linq;
using System.Collections;
class P
{
const IEnumerable e = from x in new[] { 1, 2, 3 } select x; // CS1933
static int Main()
{
return 1;
}
}