C# 中的命令列引數
如果你想透過命令列傳遞引數,請在 C# 中使用命令列引數 −
當我們使用 c# 建立程式時,會使用 static void main,並且可以在其中檢視引數。
class HelloWorld {
static void Main(string[] args) {
/* my first program in C# */
Console.WriteLine("Hello World");
Console.ReadKey();
}string[] args 是一個變數,它擁有從命令列中傳遞來的所有值,如上所示。
現在想要列印這些引數,我們假設有一個引數“One” −
Console.WriteLine("Length of the arguments: "+args.Length);
Console.WriteLine("Arguments:");
foreach (Object obj in args) {
Console.WriteLine(obj);
}以上操作將列印 −
Length of the arguments: 1 Arguments: One
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP