例子:
public partial class abc1 : Form
{
public string str__subgrp { get; set; }
public string str__type { get; set; }
public string return_str__type { get; set;
public abc1()
{
InitializeComponent();
}
private void savebtn_click(object sender, EventArge e )
{
this.str__subgrp = "ABC";
this.str__type = "123";
this.return_str__type = "This word is unicode";
}
}
public partial class worknow : Form
{
// ... declare variable in class ....
public worknow()
{
InitializeComponent();
}
private void showformbtn_click(object sender, EventArge e )
{
string a,b,c;
using ( var abc1_frm = new abc1())
{
abc1_frm.ShowDialog();
a = abc1_frm.str__subgrp;
b = abc1_frm.str__type;
c = abc1_frm.return_str__type; // This variable = null
}
}
}
在注释行中(此变量 = null)
为什么变量有return_str__type
返回null
值?