Command line arguments are parameters supplied to Main method at the time of invoking it for execution.
Example:
using System;
class cmdline;
{
public static void Main(string[] args)
{
Console.Write("Welcome");
Console.Write(" "+args[0]);
Console.WriteLine(" "+args[1]);
}
}
In the above example Main is declared with a parameter args. The two arguments assigned to the array are as:
Mr. ------------------->args[0]
Programmer--------->args[1]
the output will be.
Welcome Mr. Programmer
Example:
using System;
class cmdline;
{
public static void Main(string[] args)
{
Console.Write("Welcome");
Console.Write(" "+args[0]);
Console.WriteLine(" "+args[1]);
}
}
In the above example Main is declared with a parameter args. The two arguments assigned to the array are as:
Mr. ------------------->args[0]
Programmer--------->args[1]
the output will be.
Welcome Mr. Programmer
No comments:
Post a Comment