1

I have a string. Something like this:

myapp.exe email --to myemail@mail.com --subject "EmailSubject" --body "Test message".

How to parse every param value?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Nemesis
  • 41
  • 2
  • 10

1 Answers1

3

You can either go the manual way and build your dictionary of key-values: https://msdn.microsoft.com/en-us/library/aa288457(v=vs.71).aspx

Or use a third party Nuget package, such as this one: https://www.nuget.org/packages/commandlineparser, which will add support for more advanced and higher level scenarios

Fabio Salvalai
  • 2,479
  • 17
  • 30
  • 1
    Command line parser is incredibly useful. It saves so much time over the manual method, and is incredibly easy to plug in and get working. – David Watts Sep 22 '15 at 10:01
  • @fabilio-salvalai thank you. I have just installed this library. I'm viewing their wiki now. – Nemesis Sep 22 '15 at 10:22
  • @DavidWatts, tq. Do you have some samples that use this library? (uses verbs as "email") – Nemesis Sep 22 '15 at 10:23
  • @Nemesis nothing of my own right now, but there is an example on their codeplex page https://commandline.codeplex.com/ – David Watts Sep 22 '15 at 10:26
  • Thanks to all)) As @DavidWatts said it is very usefull and simple. I've viewed their docs and my problem is fully solved. – Nemesis Sep 22 '15 at 11:34