All about Programming and Sourcecode

Display the Command line parameters of the Main Method in C#

The Main Method in C# accepts the parameters of string Array.

You could easily display the list of parameters of the Main Method in C# by using a for/foreach loop and display the parameters like the example show below

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;

namespace ConsoleApplication4 
{     
   class Program     
   {         
     static void Main(string[] args)         
     {             
        foreach (string arg in args)                 
        Console.WriteLine("Arguments: {0}", arg);         
     }     
   } 
}
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
 
Comments

No comments yet.

Leave a Reply