本文介绍了使用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从命令行调用控制台应用程序
发布评论