using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SwitchCase
{
class SwitchCaseExample
{
//Demonstrates the use of switch...case statement along with
//the use of command line argument
static void Main(string[] userInput)
{
int input = int.Parse(userInput[0]);
//convert the string input to integer
//will throw a runtime exception if there is no input at runtime or if
//the input is not castable to integer
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 the switch block
case 2: //if it is 2
Console.WriteLine("You typed 2 (two) as the first command line argument");
break; //get out of the switch block
case 3: //if it is 3
Console.WriteLine("You typed 3 (three) as the first command line argument");
break; //get out of the switch block
default: // if it is not any of the above
Console.WriteLine("You typeda number other than 1,2,3");
break; //get out of the switch block
}
}
}
}
Oh and how do I turn line numbers on is visual studio 2010 Ultimate using C#?

New Topic/Question
Reply



MultiQuote



|