C# Program to Get and Print the Command Line Arguments Using Environment Class
In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since the last system boot in milliseconds information. By just using some predefined methods we can get the information of the Operating System using the Environment class. In this article, we will discuss how to get and display the command line arguments using the Environment class. So to do this task we use the CommandLine property of the Environment Class. This property is used to find the command line for the current process.
Return Type: The return type of this property is a string. This string represents the command-line arguments.
Input : Hello Geeks Output : Hello Geeks Input : Hello 123 Output : Hello 123
E:\> example.exe Hello Geeks Command Line Data: example.exe Hello Geeks
Please Login to comment...