0921,函数 枚举

函数:

修饰符   返回值   函数名 (形参1,形参2.....形参N) {  函数体

} 当一个流程完全封闭,完整的时候,并且需要多次使用的时候才去写函数

函数写在 main外面, class里面

无返回值无参数

无返回值 有参数的

有返回值 有参数的  

有多个返回值 

输入参数前加 out 变成输出参数

枚举:常量组
常量:变量前面加const

public void dayin()        

{            

Console.WriteLine("hello world");        

}

       

/// <summary>        

/// 求N的累加和,N是输入参数        

/// </summary>        

/// <param name="n"></param>        

/// <returns></returns>        

public int leijia(int n)        

{            

int sum = 0;            

for (int i = 1; i <= n; i++)            

{                

sum += i;            

}

            return sum;        

}

        //主函数 void是无返回值        

static void Main(string[] args)        

{

            int shuru = int.Parse(Console.ReadLine());

            int jieguo = new Program().leijia(shuru);

            Console.WriteLine(jieguo);                

    Console.ReadLine();        

}

原文地址:https://www.cnblogs.com/jlhea/p/4940740.html