在Form1中
public static Form1 f=null;
public Form1()
{
InitializeComponent();
f = this;
}
public string IP()
{
string ip;
ip ="192.168.0.1";
return ip;
}
public int PORT()
{
int port;
port =80 ;
return port;
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show();
}
Form2:
private void Form2_Load(object sender, EventArgs e)
{
textBox1.Text = Form1.f.IP();
textBox2.Text = Form1.f.PORT().ToString();
}