How in D would I cast integer to string? Something like
int i = 15
string message = "Value of 'i' is " ~ toString(i); // cast(string) i - also does not work
Google brought me the answer on how to do it with tango, but I want the phobos version.
How in D would I cast integer to string? Something like
int i = 15
string message = "Value of 'i' is " ~ toString(i); // cast(string) i - also does not work
Google brought me the answer on how to do it with tango, but I want the phobos version.
import std.conv;
int i = 15;
string message = "Value of 'i' is " ~ to!string(i);
or format
:
import std.string;
string message = format("Value of 'i' is %s.", i);
Use to
from std.conv:
int i = 15
string message = "Value of 'i' is " ~ to!string(i);
import std.conv;
auto i = 15;
auto message = text("Value of 'i' is ", i);
there are also wtext an dtext variants witch returns wstring and dstring.