110,555
社区成员
发帖
与我相关
我的任务
分享
在类里定义一个静态变量 假如类名为classname:
private static string parent;
public static string getparent
{
get
{
return parent; }
}
public static string setparent
{
set
{
parent = value;
}
}
然后在窗体form1中合适的地方写上classname cn=new classname();
cn.setparent=textBox1.Text;
在form2窗体中写上classname cn=new classname();
引用时:textBox1 .Text =cn.getparent
上面的有点错误在类里定义一个静态变量 假如类名为classname:
private static string parent;
public static string setpublic static string getparent
{
get
{
return parent; }
}
public static string setparent
{
set
{
parent = value;
}
}
然后在窗体form1中合适的地方写上classname cn=new classname();
cn.setparent=textBox1.Text;
在form2窗体中写上classname cn=new classname();
引用时:textBox1 .Text =cn.getparent