using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { //Main()是C#应用程序的入口点,执行这个函数就是执行应用程序;在Main()函数中执行完毕,执行过程就结束了; //Main()函数返回void或int,有一个可选参数string [] args. //Main()函数的四个版本 //1. static void Main(); //2. static void Main(string [] args); //3. static int Main(); //4. static int Main(string [] args); static void Main(string [] args) { Console.WriteLine("{0} command line arguments were specified:",args.Length); foreach (string arg in args) Console.WriteLine(arg); Console.ReadLine(); } } }
设置参数:
选择solution explorer--properies--debug--command line arguments.
输出结果:
时间: 2024-11-08 11:23:15