xtd 0.2.0
Loading...
Searching...
No Matches
action3.cpp

This example simplifies this code by instantiating the xtd::action delegate instead of explicitly defining a new delegate and assigning a named method to it.

#include <xtd/action>
#include <xtd/console>
#include <xtd/environment>
#include <xtd/forms/message_box>
using namespace xtd;
using namespace xtd::forms;
auto main() -> int {
auto message_target = action<const string&> {};
if (environment::get_command_line_args().size() > 1)
message_target = [](const string & message) {message_box::show(message);};
else
message_target = [](const string & message) {console::write_line(message);};
message_target("Hello, World!");
}
Implements a Windows message.
Definition message.h:28
size_t size
Represents a size of any object in bytes.
Definition size.h:23
delegate< void(arguments_t...)> action
Represents a xtd::delegate that has variable parameters and does not return a value.
Definition action.h:20
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10