函数的输入,输出
namespace HanShu
{
class Class1
{
/// <summary>
/// 这是一个加法运算的函数
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public int JiaFa(int a, int b)
{
return a + b;
}
/// <summary>
/// 无返回值,无参数
/// </summary>
public void DaYin()
{
Console.WriteLine("helloworld");
}
/// <summary>
/// 累加求和
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public int Qiuhe(int n)
{
int sum = 0;
for (int i = 1; i <= n; i++)
{
sum += i;
}
return sum;
}
}
}
namespace HanShu
{
class Program
{
//函数:是一个带有输入参数、输出参数、返回值的代码块
static void Main(string[] args)
{
int a, b;
a = 3;
b = 5;
Class1 cc = new Class1();
int c = cc.JiaFa(a,b);
Console.WriteLine(c);
cc.DaYin();
Console.WriteLine(cc.Qiuhe(5));
Console.ReadLine();
}
}
}