使用string [] args从命令行调用控制台应用程序

编程入门 行业动态 更新时间:2024-10-27 01:27:13
本文介绍了使用string [] args从命令行调用控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个.NET Console应用程序(非常简单)。入口点采用了臭名昭著的string [] args参数。这是否意味着我可以从命令行调用此应用,并将单个字符串作为参数传递?如果是,怎么办?

I have a .NET Console app (very simple). The entry point takes the infamous string[] args argument. Does this mean that from a command line, I could call this app and pass in a single string as a parameter? If so, how?

推荐答案

是的, string [] args 来自命令行。第零个元素是第一个参数,依此类推。请注意,与C或C ++不同, args [0] 不包含应用程序名称。

Yes, the string[] args is from the command line. The zeroth element is the first argument and so on. Please note unlike C or C++, args[0] doesn't contain the application name.

因此,如果您做:

application.exe arg1 arg2 arg3

然后:

args[0] = arg1 args[1] = arg2 args[2] = arg3

如果仅传递一个参数,则可用 args [0] 。

If you pass only one argument, that is available as args[0].

更多推荐

使用string [] args从命令行调用控制台应用程序

本文发布于:2023-11-13 21:52:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585415.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制台   命令行   应用程序   string   args

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!