如果需要查看更多文章,請微信搜索公眾號 csharp編程大全,需要進C#交流群群請加微信z438679770,備注進群, 我邀請你進群! ! !

form1:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int data= https://www.cnblogs.com/zyr365/archive/2020/11/24/sumData(10, 25);
MessageBox.Show(data.ToString());
}
}
}
form2:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public static int sumData(int a,int b)
{
return a + b;
}
}
}
此表單的Form2:Form 改為Form1:Form
再洗掉Form2.Designer.sc 和
public Form2(){InitializeComponent();}
這樣Form2中的代碼就可以像Form1中的代碼一樣使用了!
運行結果:

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/227010.html
標籤:.NET技术
上一篇:UDP 協議 C# UdpClient亂序接收資料包丟失的問題 Socket ReceiveBufferSize
