您能举一个调用函数和被调用函数的例子吗

您能举一个调用函数和被调用函数的例子吗

问题描述:

您能举一个调用函数和调用函数的例子吗?

can u give me example on calling function and called function

简单:

调用函数:

int res = Calc(a,b);

调用函数:

public int Calc(int a,int b)
{
返回a + b;
}
Simple:

Calling function:

int res = Calc(a, b);

Called Function:

public int Calc(int a, int b)
{
return a + b;
}


私有无效Form2_Load(对象发送者,EventArgs e)
{
MsgBox();
}

私人void MsgBox()
{
MessageBox.Show("Test");
}
private void Form2_Load(object sender, EventArgs e)
{
MsgBox();
}

private void MsgBox()
{
MessageBox.Show("Test");
}


如果您需要了解什么是C#中的函数/方法以及如何调用方法,请检查此^ ]

我正在添加与C#方法相关的另一资源.选中 [ C#中的匿名函数 [
If you need to know about what is function/method in C# and how to call a method check this tutorial[^]

I''m adding another resource related to C# methods. Check this[^]

And it is better if you can read about Anonymous Functions in C#[^]