title: Program exit codes and their meaning in Windows Console applications
body: <p>I'm developing a C# console application using .NET 5.0.</p>
  <p>This is my code:</p>
  <pre><code>namespace MyConsoleApp
  {
      class Program
      {
          static void Main(string[] args)
          {
              int portNo = -1;
  
              if (args.Length != 2)
              {
                  Console.WriteLine(&quot;Usage: MyConsoleApp port&quot;);
                  Environment.Exit(1);
              }
              else if (!int.TryParse(args[1], out portNo)) {
                  Console.WriteLine(&quot;You have to pass a valid Internet port number.&quot;);
                  Environment.Exit(1);
              }
          }
      }
  }
  </code></pre>
  <p>I have a doubt about what number do I have to return. I'm using <code>Environment.Exit(1);</code> to return 1 to the operating system but I'm not sure if this number is correct because I remember to use -1 with C++ programs.</p>
  <p>Is there any documentation about these exit codes and their meaning?</p>