as

September 14, 2025 ยท View on GitHub

Shows how to use xtd::as operator.

Sources

Build and run

Open "Command Prompt" or "Terminal". Navigate to the folder that contains the project and type the following:

xtdc run

Output

d = 41.6, convert::to_int32(d) = 42, as<int>(d) = 42
i = 42, convert::to_string(i) = 42, as<string>(i) = 42
a = string, convert::to_string(a) = string, as<string>(a) = string
p = a, convert_pointer::to_ptr<string>(p) = a, as<string>(p) = a
Bad cast : Specified cast is not valid. !
Bad cast : Specified cast is not valid. !