validate parms in my console app

  • Thread starter Thread starter rodchar
  • Start date Start date
R

rodchar

hi all,
what is the best way to accept and validate 2 dates and an int for my
console app?
so far i have:
if (args.Length==2)
//i assume it's a start date and end date
if (args.Length==1)
//i assume it's an int and just add the int amount to the start date and end
date
else
//i default the start date and end date to today's date.

does this look ok or is there a better way?

thanks,
rodchar
 
what is the best way to accept and validate 2 dates and an int for my
console app?

Have you considered utilizing a third-party API to parse your command line
arguments? A quick search reveals several such APIs targeting the .NET
platform:

http://www.google.com/search?hl=en&q=c#+command+line+parser

The approach you present is definately an option, but it might just blow
up in terms of maintainability, should you need to extend your application
in the future.
 
Back
Top