问题描述
如何使用VS2008将命令行参数值传递给c#中的主要方法
How to pass command line argument values to my main method in c# with VS2008
推荐答案
using System;
class Command
{
public static void Main(String[ ] args)
{
string name= args[0].ToString();
Console.WriteLine("Name Entered via Command Line argument is: "+name);
}
}
在此
中使用Visual Studio命令提示符编译完该文件后(csc filename.cs),然后在您运行exe之后,给您起一个名字,即
FileName Radix,然后按Enter键并查看Magic
命令行参数文件只能像这样运行,如果您尝试在开发环境中运行它,则会提示您出现异常提示
System.IndexOutOfRangeException
一旦找到有用的答案,就对我的答案进行评分
谢谢&问候
基:rose:
use the Visual Studio Command Prompt for this
Once this file is compiled(csc filename.cs) then after u run the exe then give ur name i.e
FileName Radix and then press enter and see the Magic
Command Line argument files can only run like this and if u try to run it in the development environment then it will prompt u an Exception saying
System.IndexOutOfRangeException
Do rate my answer once u find it useful
Thanks & Regards
Radix :rose:
这篇关于如何在VS2008中传递命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!