static void Main(string[] args) { var options = new Options(); try { if (CommandLine.Parser.Default.ParseArguments(args, options)) { string d = "-09/15/2015 10:00"; DateTimeOffset newdate = DateTimeOffset.Parse(d); //var date = DateTimeOffset.TryParse(d, out newdate); // Values are available here if (options.Verbose) Console.WriteLine("Filename: {0}", options.InputFile); } } catch (FormatException fe) { Console.WriteLine("wrong date "+ fe.Message); } Console.Read(); }
static void Main(string[] args) { var options = new Options(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { // consume Options instance properties if (options.Verbose) { Console.WriteLine(options.InputFile); Console.WriteLine(options.MaximumLength); } else Console.WriteLine("working ..."); } else { // Display the default usage information Console.WriteLine(options.GetUsage()); } Console.Read(); }