双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

各位大侠请帮忙,MVC/MVP模式接口编译错误,没辙了!

kmcyz kmcyz 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
很简单的一个MVP接口实现:
//View接口
namespace WebClient1.Products.Views
{
public interface IProductNewView
{
List<Product> Products { set; }
}
}

//View实现
namespace WebClient1.Products.Views
{
public partial class ProductNew : Microsoft.Practices.CompositeWeb.Web.UI.Page, IProductNewView
{
private ProductNewPresenter _presenter;
private List<Product> _p=null;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
}
this._presenter.OnViewLoaded();
}

[CreateNew]
public ProductNewPresenter Presenter
{
get
{
return this._presenter;
}
set
{
if(value == null)
throw new ArgumentNullException("value");

this._presenter = value;
this._presenter.View = this;
}
}

// TODO: Forward events to the presenter and show state to the user.
// For examples of this, see the View-Presenter (with Application Controller) QuickStart:
public List<Product> Products
{
set
{
_p = value;
}
}
}
}

//Presenter
namespace WebClient1.Products.Views
{
public class ProductNewPresenter : Presenter<IProductNewView>
{

// NOTE: Uncomment the following code if you want ObjectBuilder to inject the module controller
// The code will not work in the Shell module, as a module controller is not created by default
//
private IProductsController _controller;
public ProductNewPresenter([CreateNew] IProductsController controller)
{
_controller = controller;
}

public override void OnViewLoaded()
{
// TODO: Implement code that will be executed every time the view loads
View.Products = _controller.Products;
}
}
}

编译错误:
错误 2 “WebClient1.Products.Views.ProductNew”不实现接口成员“WebClient1.Products.Views.IProductNewView.Products”。“WebClient1.Products.Views.ProductNew.Products”无法实现“WebClient1.Products.Views.IProductNewView.Products”,因为它没有匹配的返回类型“System.Collections.Generic.List<WebClient1.Products.Interface.Product>”。 c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\webclient1\6dba2d22\5c066a95\App_Web_1wkctjkb.2.cs 15
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
kmcyz
.NET社区 62,274 成员 668,968 内容