Tuesday 6 March 2012

Passing arguments to Main in console


// Passing Arguments to Main Method using command Prompt.
using System;
class program
{
static void Main(string[] args)
{
for(int i=0;i<args.Length;i++)
{
Console.WriteLine("{0} Arguments have passed to main Method.",args.Length);
}
}
}

//Note: In order to execute this program you need to pass argument at runtime like this PassingArgumentsToMain.exe /a /b /c
//Note One Space is required to seprate the argument list.

No comments:

Post a Comment