c# public void tiqu(){ string finder = "1234567890";}private void persGSMToolStripMenuItem_Click(object sender, EventArgs e){tiqu();richTextBox1.Text = richTextBox1.Text.Replace(finder, "PersGSM");}
2 回答
aluckdog
TA贡献1847条经验 获得超7个赞
你这么编码,编译器不报错?
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");
}
桃花长相依
TA贡献1860条经验 获得超8个赞
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");
}
- 2 回答
- 0 关注
- 83 浏览
添加回答
举报
0/150
提交
取消