预期的分号......但是有一个,任何MVC.NET可以看一下吗?

时间:2009-12-21 17:06:10

标签: asp.net-mvc viewmodel

Compiler Error Message: CS1002: ; expected

Source Error:

Line 56:    </div><!--end #Asset-->
Line 57:    
Line 58:         <% KODmvc.Models.AssetRatingViewModel ratingModel = ViewData["RatingViewModel"] as KODmvc.Models.AssetRatingViewModel(); %>
Line 59:        <% Html.RenderPartial("RatingView", ratingModel); %>
Line 60: 

Source File: c:\RatingSystem\Views\Asset\ArticleView.aspx    Line: 58 

是什么给出的?第58行的分号是那里..

2 个答案:

答案 0 :(得分:7)

您正在使用as关键字转换为方法调用。

ViewData["RatingViewModel"] as KODmvc.Models.AssetRatingViewModel();

你确定这是一种方法,而不是一种类型吗?你试过去除parens吗?

ViewData["RatingViewModel"] as KODmvc.Models.AssetRatingViewModel;

答案 1 :(得分:2)

<% KODmvc.Models.AssetRatingViewModel ratingModel = ViewData["RatingViewModel"] as KODmvc.Models.AssetRatingViewModel(); %>

应该是

<% KODmvc.Models.AssetRatingViewModel ratingModel = ViewData["RatingViewModel"] as KODmvc.Models.AssetRatingViewModel; %>