

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Command Line arguments in C#
If you want to pass arguments by command line, then use command line arguments in C# −
When we create a program in c#, static void main is used and we can see the arguments in it .
class HelloWorld { static void Main(string[] args) { /* my first program in C# */ Console.WriteLine("Hello World"); Console.ReadKey(); }
The string[] args is a variable that has all the values passed from the command line as shown above.
Now to print those arguments, let’s say we have an argument, “One” −
Console.WriteLine("Length of the arguments: "+args.Length); Console.WriteLine("Arguments:"); foreach (Object obj in args) { Console.WriteLine(obj); }
The above will print −
Length of the arguments: 1 Arguments: One
- Related Questions & Answers
- Java command line arguments
- Command line arguments in Java
- Command Line Arguments in Python
- Command Line arguments in Lua
- Explain Java command line arguments.
- Command Line arguments in Java programming
- Command line arguments in C/C++
- Command line arguments example in C
- Command Line and Variable Arguments in Python?
- How to Parse Command Line Arguments in C++?
- How to add command line arguments in Python?
- How do we access command line arguments in Python?
- getopt() function in C to parse command line arguments
- How command line arguments are passed in main method in C#?
- Command Line Interpreters
Advertisements