SoFunction
Updated on 2025-03-07

C# How to read parameters from the command line

This article describes how C# reads parameters from the command line. Share it for your reference. The details are as follows:

using System;
class MainClass
{
 public static void Main(string[] args)
 {
  foreach (string arg in args)
  ("Arg: {0}", arg);
 }
}

Save the above code as:, edit the source file:

csc 

Execute the command:

 

The output is as follows:

Arg:

I hope this article will be helpful to everyone's C# programming.