我有这段代码:
public void button1_Click(object sender, EventArgs e)
{
for(int i = 0; i < numericUpDown1.Value; i++)
{
WebBrowser webBrowser = new WebBrowser();
webBrowser.Visible = false;
webBrowser.ScriptErrorsSuppressed = true;
webBrowser.Navigate("want to keep it private.");
webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);
}
}
public void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlElement botNick = webBrowser.Document.GetElementById("nick");
botNick.SetAttribute("value", textBox1.Text);
HtmlElement botPlay = webBrowser.Document.GetElementsByTagName("button")[2];
botPlay.InvokeMember("click");
}
为什么我得到&#34;名称&#34; webBrowser&#34;在当前上下文中不存在&#34;?