Best way to parse command line arguments in C#
- by Paul Stovell
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.