What are Command Line Arguments?
• Command line arguments are the parameters
we pass to the Main Function of any
application or program via String Array. We
can pass n numbers of parameters via this
String array in Main Method or function.
• Main Function In c#
Public static void Main( String []args )
{
}
Why do we need command line
arguments?
• The command line arguments come handy in
that situation when our Main function or so
called entry point of our program required
some arguments to manipulate when starting
the execution of program.
How to Use command line arguments
in Visual Studio?
1. Create a executable program
• The following Program is an executable program that is showing arguments on
command.
using System;
namespace CommandLineApplication
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < args.Length; i++)
{
Console.WriteLine("Arguments Values are {0}", args[i]);
}
Console.Read();
}
}
}
Passing Command Line Arguments in Visual Studio
1. Right-click on "Project" -> "Properties". Then in the right panel is
"Debug"; enter arguments into the Command line arguments
textbox
Command Line Arguments in C#

Command Line Arguments in C#

  • 1.
    What are CommandLine Arguments? • Command line arguments are the parameters we pass to the Main Function of any application or program via String Array. We can pass n numbers of parameters via this String array in Main Method or function. • Main Function In c# Public static void Main( String []args ) { }
  • 2.
    Why do weneed command line arguments? • The command line arguments come handy in that situation when our Main function or so called entry point of our program required some arguments to manipulate when starting the execution of program.
  • 3.
    How to Usecommand line arguments in Visual Studio? 1. Create a executable program • The following Program is an executable program that is showing arguments on command. using System; namespace CommandLineApplication { class Program { static void Main(string[] args) { for (int i = 0; i < args.Length; i++) { Console.WriteLine("Arguments Values are {0}", args[i]); } Console.Read(); } } }
  • 4.
    Passing Command LineArguments in Visual Studio 1. Right-click on "Project" -> "Properties". Then in the right panel is "Debug"; enter arguments into the Command line arguments textbox