Getsuyodev, Programming is mainly used when constructing an application. Programming requires knowledge of application domains, algorithms, and programming language expertise. Programming can be developed in different logic based on developer knowledge.

C# Command line arguments

We can pass command line arguments to C# programs. The program accept arguments in the order of args[0], args[1] etc. The following program shows how to pass command line arguments to the c# program. Open a new text document and copy and paste the following source code and save the file as “NewProg.cs”

using System;

class NewProg
	static void Main(string[] args)
		Console.WriteLine("Arguments-1 " + args[0]+"   Argument-2 "+args[1]);

Go to the command prompt and issue the following command for compilation.
csc NewProg.cs

After the successful compilation you will get NewProg.exe file

When you execute this C# program you have to pass two arguments with the filename.

NewProg test1 test2

you will get the output like Arguments-1 test1 Argument-2 test2

Comments are closed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More