validate parms in my console app

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
 
J

Joern Schou-Rode

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top