class Program { /// <summary> /// 无参数,无返回值 /// </summary> /// <param name="args"></param> static void n1() { Console.WriteLine("这是第一种方法"); } /// <summary> /// 有参数,无返回值 /// </summary> /// <param name="args"></param> static void n2(string a) //这里必须是静态 { Console.WriteLine(a); } /// <summary> /// 无参数,有返回值 /// </summary> /// <returns></returns> static int n3() { return 100; } /// <summary> /// 有参数有,返回值 /// </summary> /// <param name="args"></param> static int n4(string name) { Console.WriteLine(name); return 100; } static void Main(string[] args) { n1(); Console.WriteLine("请输入一个字符串"); string s = Console.ReadLine(); n2(s); int b=n3(); Console.WriteLine("返回值为" + b); int i = n4("有参数,有返回值"); Console.WriteLine("返回值为" + i); Console.ReadLine(); } }
时间: 2024-10-17 06:50:48