请帮我看看是哪里有问题,该如何改正??

c# 
public void tiqu()
{  
string finder = "1234567890";
}
private void persGSMToolStripMenuItem_Click(object sender, EventArgs e)
{
tiqu();
richTextBox1.Text = richTextBox1.Text.Replace(finder, "PersGSM");

}

蛊毒传说
浏览 84回答 2
2回答

aluckdog

你这么编码,编译器不报错?public String tiqu(){  string finder = "1234567890";return finder;}private void persGSMToolStripMenuItem_Click(object sender, EventArgs e){string finder =tiqu();richTextBox1.Text = richTextBox1.Text.Replace(finder, "PersGSM");} 

桃花长相依

public void tiqu(){  string finder = "1234567890";}finder是一个局部变量,当这个函数执行完毕的时候,finder已经释放了,在内存中已经不存在了。可以修改为public string tiqu(){  string finder = "1234567890";return finder;}private void persGSMToolStripMenuItem_Click(object sender, EventArgs e){string fineder = tiqu();richTextBox1.Text = richTextBox1.Text.Replace(finder, "PersGSM");}
打开App,查看更多内容
随时随地看视频慕课网APP