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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP