为什么我会得到参数1,不得与' ref&#x27传递。关键词?
我试图通过引用从1到Form2传递字符串,要在Form2中修改字符串,并在Form1中使用更改的值。 这是我的代码:
内部form1.cs:
private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
string text = "aaa";
Form frm2 = new Form2();
frm2.ShowDialog(ref text);
}
内部form2.cs
public void ShowDialog(ref string von1)
{
textBox1.Text = von1;
this.ShowDialog();
von1 = textBox1.Text;
}
我无法编译该项目,因为im遇到错误:
参数1可能不会与“ ref”关键字CS1615传递,
我在做什么错?
I am trying to pass an string by reference from From1 to Form2, want to modify the string in Form2 and use the altered value in Form1.
This is my code:
Inside Form1.cs:
private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
string text = "aaa";
Form frm2 = new Form2();
frm2.ShowDialog(ref text);
}
Inside Form2.cs
public void ShowDialog(ref string von1)
{
textBox1.Text = von1;
this.ShowDialog();
von1 = textBox1.Text;
}
I'm not able to compile this project because im getting the error:
Argument 1 may not be passed with the 'ref' keyword CS1615
What am i doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论