Command line argument in C#

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

Introduction

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.

Example

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]);

        Console.ReadLine();

      }

   }

}


  

© 2020 DotNetHeaven. All rights reserved.