English 中文(简体)
我有这样的错误:CS1001(C#)和CS1026。 但不知道如何解决该问题。
原标题:I have this error CS1001 (C#) and CS1026 ..But do not know how tosolve it

i 反映这一错误:

Compiler Error Message: CS1001: Identifier expected

摘自这套法典:

var reqcategory=""; 
        foreach(Request["category"] as reqcategory)
        {
        var sql5 = "SELECT Type.PreReq1, Type.PreReq2, (CASE WHEN (Type.PreReq1 IS NOT NULL) AND (PermitApp1.RPClass IS NULL) AND (PermitApp1.RPCategory IS NULL) THEN 1 ELSE 0 END) AS missing1, (CASE WHEN (Type.PreReq2 IS NOT NULL) AND (PermitApp2.RPClass IS NULL) AND (PermitApp2.RPCategory IS NULL) THEN 1 ELSE 0 END) AS missing2 FROM Type LEFT JOIN PermitApp AS PermitApp1 ON (Type.PreReq1=PermitApp1.RPClass) OR (Type.PreReq1=PermitApp1.RPCategory) AND ( PermitApp1.CDSID = @0 ) AND (PermitApp1.MDecision= 1 ) LEFT JOIN PermitApp AS PermitApp2 ON (Type.PreReq2=PermitApp2.RPClass) OR (Type.PreReq2=PermitApp2.RPCategory) AND ( PermitApp2.CDSID = @1 ) AND (PermitApp2.MDecision= 1 ) WHERE Type.PType = @2";
        var result = db.QuerySingle(sql5, myCDSID, myCDSID, reqcategory);
        var miss1 = result.missing1;
        var miss2 = result.missing2;
        }

The error happens to fall on this line:

foreach(Request["category"] as reqcategory)

正如汇编者所强调的那样。

谁能告诉我我的错误是什么? 如何宣布身份识别?

什么是识别? 在

如果使用<代码>int.parse 权利,但如果它正在扼杀......怎么能够这样做?

成就 成就

BTW 我正在使用网络矩阵。

在使用JardedPar 解决办法之后......下一个错误是......

CS1026: ) expected

这一部分:

if (miss1 ==  1  or miss2 ==  1 ){
            ModelState.AddError("missing", "You have not met the Pre-Requisites for "+ cat +" yet.")
            } else if (miss1 ==  0  and miss2 ==  0 ){

        Session["license"] = Request["licence"];
        Session["from"] = Request["from"];
        Session["to"] = Request["to"];
        Session["group"] = Request["group"];
        Session["class1"] = Request["class1"];
        Session["category1"] = Request["category1"];
        Session["class"] = Request["class"];
        Session["category"] = Request["category"];
        Response.Redirect("~/Questionnaire");
        }

on this line:

if (miss1 ==  1  or miss2 ==  1 ){

...... 我看不出为什么需要(在那里......我已经关闭了所有这一切)。

最佳回答

The problem is you have the structure of the foreach loop backwards. In C# it s identifire in collection.

foreach(var reqcategory in Request["category"]) { 
  ...
} 

请注意,即使这一胜利也足以作为<代码>。 要求[...] 回归代码>,在C#中为有效收集类型。 请具体说明基本收集或使用<代码>dnamic的类型。 最安全的选择是投到<代码>。 缩略语

foreach(object reqcategory in (IEnumerable)Request["category"]) { 
  ...
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签