Command line argument in C#

In this article we can learn about Command line argument in C#.
  • 3774


We can easily pass a parameter to a method in C#. These parameters are pass to a method as argument. In Main(string[] args) function parameters can be passed to a main() method and it is call command line argument. It is an array type parameter.


using System;

using System.Collections.Generic;

using System.Text;

using System.Reflection;

namespace commandlineargument


  class Command


     static void Main(string[] args)


         // command line argument

        Console.WriteLine("My First Name is " + args[0]);

        Console.WriteLine("My Last Name is " + args[1]);






© 2020 DotNetHeaven. All rights reserved.