C#,创建新表单时如何通过引用传递? [英] C#, How do I pass by reference when creating a new form?

查看:112
本文介绍了C#,创建新表单时如何通过引用传递?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码有效:

The following code works:

private void button1_FastSetup1(object sender, System.EventArgs e)
     {
         WiFi_Fast_Setup_Form1 fs = new WiFi_Fast_Setup_Form1(
             NetworkName_tB.Text,
             PassPhrasetBox.Text,
             emailServer_tB.Text,
             To_Email_textBox.Text,
             CC_Email_tB.Text,
             BCC_textBox.Text,
             subject_TxtBox.Text,
             rTBox_Body_Message.Text
             );
         fs.ShowDialog();
     }





但这不是:





But this does not:

private void button1_FastSetup1(object sender, System.EventArgs e)
{
    WiFi_Fast_Setup_Form1 fs = new WiFi_Fast_Setup_Form1(
        ref string NetworkName_tB,
        ref string PassPhrasetBox,
        ref string emailServer_tB,
        ref string To_Email_textBox,
        ref string CC_Email_tB,
        ref string BCC_textBox,
        ref string subject_TxtBox,
        ref string rTBox_Body_Message
    );
    fs.ShowDialog();
}



使用引用(指向字符串的指针)正是我需要的。

但是怎么做我开始工作了吗?



JimOr


Using a reference (pointer to string) would be exactly what I need.
But how do I get it to work?

JimOr

推荐答案

使用System.Windows;







application.current.resources [NetworkName_tB]; //就像网络中的会话
using System.Windows;



application.current.resources["NetworkName_tB"];// is like session in web


'ref'关键字必须位于起始实例上并放在接收函数中。

我的问题是我没有意识到Visual编译器正在查看接收函数调用还没有'ref'关键字。
The 'ref' keyword must reside on the starting instance and be placed in the receiving function.
my problem was that I did not realize that the Visual compiler was looking at the receiving function invocation which did not yet have the 'ref' keyword.


这篇关于C#,创建新表单时如何通过引用传递?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆