return value from a application

Hello,

I'm developing an command line tool which is started by another application Is there a way to handle all posiple errors with in my application an set an error code for the application manual at the end, so that i can tell the application, which started the commandline tool, that there was an error

Thanks,
Chris



Answer this question

return value from a application

  • Gene vantreese

    Dont forget to mark the helpful post(s) as answers :)

  • Mobile Rob

    You might see your Main method written as:
    void Main() { ... }
    or
    void Main(string[] args) { ... }
    but the full signature of Main is:
    int Main(string[] args) { ... }
    which allows you to return any integer return value you want to indicate an error as CommonGenius mentions.


  • nmullane

    Store the code in an appropriate place (e.g. a global variable), then return it from your Main method.

  • Shamez

    Thanks a lot...
  • Dan Hess

    Yes

    when exiting the application do:

    Environment.Exit(int theErrorNumber)

    you can specify to the Exit() method an error number



  • return value from a application