using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { 在class Program中定义 有参数无返回值函数名前加void 无参数有返回值在函数名前加返回值的类型 //访问修饰符 函数名(参数1,参数2) //{ //函数体 //return 返回值 //} /// <summary> /// 无参数,无返回值 /// </summary> 1 public static void abc() { Console.WriteLine("无参数,无返回值"); } /// <summary> /// 无参数,有返回值 /// </summary> 2 /// <param name="args"></param> public static int abc2() { return 1; } /// <summary> /// 有参数,无返回值 /// </summary> /// <param name="args"></param> 3 public static void abc3(int a,int b) { Console.WriteLine(a + b); } /// <summary> /// 有参数,有返回值 /// </summary> /// <param name="args"></param> 4 public static int abc4(int x,int y) { return x * y; } struct stu { public int id; public string name; public DateTime birthday; public double mark; public int age; } static void Main(string[] args) { //abc(); //Console.WriteLine(abc2()); //abc3(1, 2); //Console.WriteLine(abc4(2, 3)); Console.ReadLine(); } } }