2010-09-02 29 views
2

得到了werid問題有看法,如果我元組和類型視圖的錯誤?

Inherits="System.Web.Mvc.ViewPage<List<Tuple<string, DateTime?, double?, double?, double?>>>" 

定義它,我得到的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 { 

,但完全如果我刪除最後它workes「雙擊?」。 asp.net comiller中的錯誤?

回答

3

是的,ASP.NET編譯器生成的代碼在您的示例中被破壞。我可以重新創建這個(Visual Studio 2010中,.NET 4,ASP.NET MVC 2),得到:

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; 
    ... 

顯然,有一個極限它可以採用的數量爲abuse

2

雖然我不是使用不知道爲什麼你的代碼不能編譯(它看起來右)Tuple我會強烈建議您使用視圖模型(甚至可能編譯器扼流圈醜陋:-)) :

Inherits="System.Web.Mvc.ViewPage<List<MyViewModel>>" 

有:

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

更具可讀性比:

<%: Model.Item1 %> 
<%: Model.Item2 %> 
相關問題