Best way to parse command line arguments in C#
Posted
by Paul Stovell
on Stack Overflow
See other posts from Stack Overflow
or by Paul Stovell
Published on 2009-01-29T13:33:28Z
Indexed on
2010/04/03
3:03 UTC
Read the original article
Hit count: 316
c#
|command-line
When building console applications that take parameters, you can use the arguments passed to Main(string[] args). In the past I've simply indexed/looped that array and done a few regular expressions to extract the values. However, when the commands get more complicated, the parsing can get pretty ugly.
More recently, I built the world's simplest Backus-Naur Form parser in C# to parse the arguments. It does the job, but it also feels like overkill.
So I'm interested in:
- Libraries that you use
- Patterns that you use
Assume the commands always adhere to common standards such as answered here.
© Stack Overflow or respective owner