thanx.. it is working... On Tue, Jun 29, 2010 at 12:06 PM, Raghupathi Kamuni <[email protected]>wrote:
> If you are debugging this using Visual Studio, > > In VS 2008, right click the project, choose properties, go to the Debugging > section -- there is a box for command line arguments. > > In this box you enter the value for Switch, Visual studio automatically > passes these values to Main() > > Alternatively, you can compile the program using C# compiler from the > Visual Studio command prompt and pass the parameters from command line while > executing > > If you named this file say as "SwitchCaseExample.cs" > > Compile using Visual Studio Command prompt > csc SwitchCaseExample.cs > > Execute the program with command line input > SwitchCaseExample <YourInput> > > E.g > SwitchCaseExample 1 > > > On Tue, Jun 29, 2010 at 11:33 AM, Raghupathi Kamuni <[email protected] > > wrote: > >> This program expects input from command line, while executing you have to >> enter your input for the switch statement >> >> If you named this file say as "SwitchCaseExample.cs" >> >> Compile using Visual Studio Command prompt >> csc SwitchCaseExample.cs >> >> Execute the program with command line input >> SwitchCaseExample <YourInput> >> >> E.g >> SwitchCaseExample 1 >> SwitchCaseExample 2 >> SwitchCaseExample 5 >> >> On Mon, Jun 28, 2010 at 2:26 PM, nisalm <[email protected]> wrote: >> >>> I got an error called {"Index was outside the bounds of the array."} >>> >>> my code is looks like this..... >>> >>> >>> using System; >>> using System.Collections.Generic; >>> using System.Linq; >>> using System.Text; >>> >>> >>> namespace Switch >>> { >>> class SwitchCaseExample >>> { >>> static void Main(string[] userInput) >>> { >>> int input = int.Parse(userInput[0]); >>> >>> switch (input) // what is input >>> { >>> case 1: //if it is 1 >>> Console.WriteLine("You typed 1 (one) as the first >>> command line argument"); >>> break; // get out of switch block >>> case 2: // if it is 2 >>> Console.WriteLine("You typed 2 (two) as the first >>> command line argument"); >>> break; // get out of switch block >>> case 3: // if it is 3 >>> Console.WriteLine("You typed 3(three) as the first >>> command line argument"); >>> break; // get out of switch block >>> default: // if it is not any of the above >>> Console.WriteLine("You typed a number other than >>> 1,2 and 3"); >>> break; // get out of switch block >>> >>> } >>> } >>> } >>> } >>> >>> >> >
