Okay, I'm pretty embarrassed by the fact I've been outsmarted by a handful of lines of code. I'm trying to follow this guide to get myself started with C#. The guide is quite good, but I'm stumped on part of it. Whether its because it's late or the beer I'm doing my nut in trying to work this out.
I'm up to the "Adding things to do" section of the guide linked to above, which is basically passing an argument from the command line and doing something with it. I keep getting an error when trying to run what I've written. I've boiled it down somewhat from the guide for simplicity - the error is the same:
And the error is:
I should be able to do "$ mono ./toDoList.exe add" to make it spit out "Hello" and anything else to spit out "Goodbye".
I'm going to go to bed now and hope someone has pointed out the obvious to me when I check back tomorrow.
Cheers guys & girls.
I'm up to the "Adding things to do" section of the guide linked to above, which is basically passing an argument from the command line and doing something with it. I keep getting an error when trying to run what I've written. I've boiled it down somewhat from the guide for simplicity - the error is the same:
Code:
using System;
//using System.IO;
namespace toDoList
{
class MainClass
{
public static void Main(string[] args)
{
if (args[0] == "add")
{
Console.WriteLine("Hello");
}
else
{
Console.WriteLine("Goodbye");
}
}
}
}
And the error is:
Code:
Unhandled Exception: System.IndexOutOfRangeException: Array index is out of range.
at toDoList.MainClass.Main (System.String[] args) [0x00000] in /home/mh/toDoList/toDoList/Main.cs:16
I should be able to do "$ mono ./toDoList.exe add" to make it spit out "Hello" and anything else to spit out "Goodbye".
I'm going to go to bed now and hope someone has pointed out the obvious to me when I check back tomorrow.
Cheers guys & girls.
