I was learning about the switch...case statement and i cant find out whats wrong with the following code. Once i debug i goes back to visual studio and gives me a error. An unhandled exception of type 'System.IndexOutOfRangeException' occurred in C sharp.exe
Additional information: Index was outside the bounds of the array.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C_sharp
{
class Program
{
//this will demonstrate the switch statement
static void Main(string[] userInput)
{
int input = int.Parse(userInput[0]);
switch(input)
{
case 1:
Console.WriteLine("you typed 1 (one) as the first command line argument");
break;
case 2:
Console.WriteLine("you typed 2 (two) as the first command line argument");
break;
case 3:
Console.WriteLine("you 3 (three) as the first command line argument");
break;
}
}
}
}
prog input
– Rahul Apr 24 '14 at 21:14