Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C#

Tham số dòng lệnh (Command line arguments) trong Main C#


Entry point Main() nhận string[] args.

static void Main(string[] args)

args chứa các đối số. Ví dụ 2 args: var args = new string[] {"arg1","arg2"};

Ví dụ

using System;
namespace Demo {
    class HelloWorld {
        static void Main(string[] args) {
            Console.WriteLine("Welcome here!");
            Console.ReadKey();
        }
    }
}

Biên dịch command-line: csc helloworld.cs -> helloworld.exe -> chạy helloworld.