c# 函数问题

来源:百度知道 编辑:UC知道 时间:2024/06/24 00:53:23
用C#写一个函数 需要从用户在一个界面的textbox的输入得到一个string 然后点一个按钮后把同样的数据从另外一个textbox中显示出来 怎么做到

下面是在textBox2.Text中显示textBox1.Text;中的内容
private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text;
}

private static string text;

private void button1_Click(object sender, EventArgs e)
{
text=textBox1.Text;
textBox2.Text = text;
}

或者你就直接:
private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text;
}
上面那个是通过赋值给一个string变量中转下