我得到一個錯誤,當我打下面的代碼行:爲<type>的最佳重載的方法匹配具有一些無效參數
using (_client = new RestClient("url", this))
錯誤:最好的重載方法「MyNamespace.RestClient比賽(MyNamespace.MyPresenter,字符串)'有一些無效的參數
我看了上百萬這些「最好的重載方法匹配」的線程,但我的問題似乎是不同的東西。詳細的編譯器輸出說它不能轉換:
MyPresenter [C:\ path \ to \ class \ file]到 MyPresenter [C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ Temporary 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";
}
}
'我可以給多一些有關我的班級結構的詳細信息,如果有必要的話'您向我們提供的信息是什麼? – 2014-10-08 21:40:27
你最好在這裏下注'SuperFly'是爲了展示一些代碼。 – MethodMan 2014-10-08 21:43:32