xtd 0.2.0
environment_exit_code.cpp

Shows how to use xtd::environment::exit_code method.

#include <xtd/console>
#include <xtd/environment>
#include <xtd/startup>
using namespace xtd;
namespace environment_exit_code_example {
class program {
public:
// The main entry point for the application.
static auto main() {
if (args.size() == 1)
else {
auto value = 0l;
if (try_parse(args[1], value))
if (value <= std::numeric_limits<int>::min() || value >= std::numeric_limits<int>::max())
else
console::write_line("Result: {0}", value * 2);
else
}
}
};
}
startup_(environment_exit_code_example::program::main);
// This code produces the following output :
//
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static xtd::argument_collection get_command_line_args()
Returns a string array containing the command-line arguments for the current process.
static int32 exit_code() noexcept
Gets the exit code of the process.
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:167
bool try_parse(const std::basic_string< char > &str, value_t &value) noexcept
Convert a string into a type.
Definition parse.hpp:416
@ l
The L key.
Definition console_key.hpp:110
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8