Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 元组和类型化视图的Bug?_C#_Asp.net_Asp.net Mvc - Fatal编程技术网

C# 元组和类型化视图的Bug?

C# 元组和类型化视图的Bug?,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,如果我使用定义视图,则视图存在werid问题 Inherits="System.Web.Mvc.ViewPage<List<Tuple<string, DateTime?, double?, double?, double?>>>" Inherits=“System.Web.Mvc.ViewPage” 我得到了werid错误: CS1003: Syntax error, '>' expected Line 118: public class v

如果我使用定义视图,则视图存在werid问题

Inherits="System.Web.Mvc.ViewPage<List<Tuple<string, DateTime?, double?, double?, double?>>>"
Inherits=“System.Web.Mvc.ViewPage”
我得到了werid错误:

CS1003: Syntax error, '>' expected
Line 118:    public class views_report_intrestcalc_aspx : System.Web.Mvc.ViewPage<List<Tuple<string, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
CS1003:语法错误,应为'>'

第118行:public class views\u report\u intrestcalc\u aspx:System.Web.Mvc.ViewPage虽然我不知道为什么您的代码不编译(看起来很正确),而不是使用
元组
,但我强烈建议您使用视图模型(甚至可能编译器也会因为丑陋而窒息:-):

Inherits=“System.Web.Mvc.ViewPage”
具有:

<%: Model.Username %>
<%: Model.Date %>

的可读性远远高于:

<%: Model.Item1 %>
<%: Model.Item2 %>

是的,ASP.NET编译器为您的示例生成的代码已损坏。我可以重新创建此文件(Visual Studio 2010、.NET 4、ASP.NET MVC 2)并获得:

public class views\u home\u index\u aspx:System.Web.Mvc.ViewPage
<%: Model.Item1 %>
<%: Model.Item2 %>
public class views_home_index_aspx : System.Web.Mvc.ViewPage<List<Tuple<string,
        System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
    private static bool @__initialized;
    ...
public class views_home_index_aspx : System.Web.Mvc.ViewPage<List<Tuple<string,
        DateTime?, double?, double?, double?>>>, 
        System.Web.SessionState.IRequiresSessionState,
        System.Web.IHttpHandler {
    private static bool @__initialized;
    ...