您好我正在尝试使用MONO IDE向C#发送两个参数,但我这样做是没有意义的。我收到以下错误。
Unhandled Exception: System.IndexOutOfRangeException: Array index is out of range.
at Command.Main (System.String[] args) [0x00000] in /media/EE76D9DA76D9A39D/C#/Command.cs:6
[ERROR] FATAL UNHANDLED EXCEPTION: System.IndexOutOfRangeException: Array index is out of range.
at Command.Main (System.String[] args) [0x00000] in /media/EE76D9DA76D9A39D/C#/Command.cs:6
这是我的计划:
using System;
class Command
{
static void Main(String[] args)
{
Console.WriteLine("Hi {0} , Welcome to {1}",args[0],args[1]);
}
}
提前致谢。
答案 0 :(得分:5)
我相信你的意思是MonoDevelop是IDE。如果这是真的,那么转到项目选项(通过右键单击项目并选择选项或通过项目菜单和(项目名称)选项位置),然后转到运行>常规,您可以在参数编辑框中输入所需的参数。
答案 1 :(得分:1)
你是怎么称呼这个节目的?
如果您只是在IDE中运行Run,它将在没有参数的情况下运行。然后args将是一个空字符串数组(string[0]
),因此你得到了异常。
尝试从命令行调用它并传递两个参数。