I know this is a simplex problem, but I can't figure this out. This is my first C# console program and it crashes at runtime.
I went thru all the code, that was in my book and did not find the error.
Error: Index out of range.
The error points to:
int iChoice = int.Parse(args[0]);
'code
class Greetings {
public static void DisplayEnglish() {
Console.WriteLine("Hello, world!");
}
public static void DisplayItalian() {
Console.WriteLine("Ciao, mondo!");
}
public static void DisplaySpanish() {
Console.WriteLine("Hola, imundo!");
}
}
delegate void delGreetings();
class HelloWorld {
static void Main(string [] args) {
int iChoice = int.Parse(args[0]);
delGreetings[] arrayofGreetings ={
new delGreetings(Greetings.DisplayEnglish),
new delGreetings(Greetings.DisplayItalian),
new delGreetings(Greetings.DisplaySpanish)};
arrayofGreetings[iChoice - 1]();
}
}
I went thru all the code, that was in my book and did not find the error.
Error: Index out of range.
The error points to:
int iChoice = int.Parse(args[0]);
'code
class Greetings {
public static void DisplayEnglish() {
Console.WriteLine("Hello, world!");
}
public static void DisplayItalian() {
Console.WriteLine("Ciao, mondo!");
}
public static void DisplaySpanish() {
Console.WriteLine("Hola, imundo!");
}
}
delegate void delGreetings();
class HelloWorld {
static void Main(string [] args) {
int iChoice = int.Parse(args[0]);
delGreetings[] arrayofGreetings ={
new delGreetings(Greetings.DisplayEnglish),
new delGreetings(Greetings.DisplayItalian),
new delGreetings(Greetings.DisplaySpanish)};
arrayofGreetings[iChoice - 1]();
}
}