title: Specifying the Return Error Code on Application Exit
body: <p>How can the return error code be specified on application exit?  If this were a VC++ application, I could use the <code>SetLastError(ERROR_ACCESS_DENIED)</code> -- <code>return GetLastError()</code> APIs.  Is there a way to do this in C#?</p>
  
  <pre><code>  static int Main(string[] args)
    {
       Tool.Args = args;
  
       Application.EnableVisualStyles();
       Application.SetCompatibleTextRenderingDefault(false);
       Application.Run(new Download_Tool());
  
       return Tool.ErrorCode;
    }
  </code></pre>
  
  <p>How can the <code>Tool.ErrorCode</code> value be set intelligably?  If I try something like <code>Tool.ErrorCode = ERROR_ACCESS_DENIED</code>, I get an error, "The name ERROR_ACCESS_DENIED does not exist in the current context."  Thanks.</p>
  
  <p><em>ADDITIONAL INFORMATION</em></p>
  
  <p>My example is over-simplified.  Is there a way to something like this:</p>
  
  <pre><code>Tool.ErrorCode = ERROR_ACCESS_DENIED;
  return Tool.ErrorCode;
  </code></pre>
  
  <p>...which generates a compile-error, rather than this:</p>
  
  <pre><code>Tool.ErrorCode = 5;
  return Tool.ErrorCode;
  </code></pre>
  
  <p>...which works, but uses a "magic number."  I'd like to avoid the use of magic numbers.</p>