先把Form1 new一下Form1 f = new Form1();Form1 中有一个名为A的公共类f.a();就可以了
我在Form1()中已经有socket连上服务器了,在Form2中怎么在用这个socket啊
public Form2(Socket xx) {} Form2 frm=new Form2(Socket); frm.show(); 这个是笨办法
class Form1 : Form { // 在 Form1 中声明为静态的: public static void S() { // ... } }class Form2 : Form { void Foo() { Form1.S(); // <------ 在 Form2 中这样用 Form1 中的静态方法 } }
在form1中声明的结果体在form2中怎么用啊
class Form1 : Form { public static void S(){} public void Func(){} }class Form2 : Form { void Foo() { Form1.S(); // <------ 在 Form2 中这样用 Form1 中的静态方法 new Form1().Func(); // <------ 这样用 Form1 中的非静态方法 } }
在form1中声明的结果体在form2中怎么用啊
public partial class Form1 : Form { public Form1() { InitializeComponent(); } public struct xx { int i ; int j ; public static void TT() { i = 0; j = 1; } } } namespace WindowsFormsApplication16 { public partial class Form2 : Form { public Form2() { InitializeComponent(); Form1.xx.TT(); }
} }
在form1中声明的结果体在form2中怎么用啊
在form2中找不到定义的结构体?
class Form1 : Form { public struct St{} }class Form2 : Form { Form1.St st = new Form1.St(); // <---- 这样用 }
{}
Form2 frm=new Form2(Socket);
frm.show();
这个是笨办法
{
// 在 Form1 中声明为静态的:
public static void S()
{
// ...
}
}class Form2 : Form
{
void Foo()
{
Form1.S(); // <------ 在 Form2 中这样用 Form1 中的静态方法
}
}
{
public static void S(){}
public void Func(){}
}class Form2 : Form
{
void Foo()
{
Form1.S(); // <------ 在 Form2 中这样用 Form1 中的静态方法
new Form1().Func(); // <------ 这样用 Form1 中的非静态方法
}
}
{
public Form1()
{
InitializeComponent();
}
public struct xx
{
int i ;
int j ;
public static void TT()
{
i = 0;
j = 1;
}
}
}
namespace WindowsFormsApplication16
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
Form1.xx.TT();
}
}
}
class Form1 : Form
{
public struct St{}
}class Form2 : Form
{
Form1.St st = new Form1.St(); // <---- 这样用
}