110,533
社区成员
发帖
与我相关
我的任务
分享
//form1:
public partial class Form1 : Form
{
public delegate void MyDel(string value);
public event MyDel txtzt;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2(this);//this这里说的是指针,伏笔
f2.Show();
}
}
//form2
public partial class Form2 : Form
{
public Form2(Form1 f1)//Form1吗?你确定不是Form1*吗?刚才明明给的是指针呀
{
InitializeComponent();
f1.txtzt += new Form1.MyDel(txtzt);
}
private void txtzt(string s)
{
this.textBox1.Text = s;
}
}
void caculate1(string s);
string str1=“ABCD”;
caculate1(str1);
我还要担心:传给函数的参数str1值会被这个函数篡改?
传参数就再也不安全呀!