最佳重载方法匹配<;类型>;有一些无效的参数
本文关键字:无效 参数 gt 类型 重载 lt 最佳 方法 | 更新日期: 2023-09-27 18:25:56
当我遇到以下代码行时,我得到了一个错误:
using (_client = new RestClient("url", this))
错误:与"MyNamespace.RestClient(MyNamespace.MyPresenter,string)"匹配的最佳重载方法具有一些无效参数
我已经研究了一百万个这样的"最佳重载方法匹配"线程,但我的问题似乎有所不同。详细的编译器输出表示无法从转换
MyPresenter[C:''path''to''class''file]到MyPresenter[C:''Windows''Microsoft.NET''Framework64''v4.0.30319''临时ASP.NET Files''root''3d988ef4''66e82b30''assembly''dl3''995d0d63''042c184e_aae2cf01''ProjectName.DLL]
我不确定这里出了什么问题。类型相同。
这是我的完整代码(ASP.net中的MVP模式):
// default.aspx.cs (View class)
public partial class MyView : Page
{
private readonly MyPresenter _presenter;
public MyView()
{
_presenter = new MyPresenter(this);
}
public TextBox OutputText
{
get { return outputText; }
}
protected void Page_Load(object sender, EventArgs e) {}
protected void GoButton_OnClick(object sender, EventArgs eventArgs)
{
_presenter.DoStuff();
}
}
// default.aspx.designer.cs
public partial class MyView
{
protected global::System.Web.UI.WebControls.Button goButton;
protected global::System.Web.UI.WebControls.TextBox outputText;
}
// MyPresenter.cs
public class MyPresenter
{
private RestClient _client;
public MyPresenter(MyView view)
{
View = view;
}
public MyView View { get; private set; }
public void DoStuff()
{
**using (_client = new RestClient("url", this))** // Error here
{
_client.DoClientStuff()
}
}
}
// RestClient.cs
public class RestClient
{
private readonly MyPresenter _presenter;
private readonly string _url;
public RestClient(string url, MyPresenter presenter)
{
_presenter = presenter;
_url = url;
}
public void DoClientStuff()
{
_presenter.View.OutputText.Text = "Doing client stuff";
}
}
您的参数向后
using (_client = new RestClient("url", this))
应该是
using (_client = new RestClient(this, "url"))