Ответ 1
import std.conv;
int i = 15;
string message = "Value of 'i' is " ~ to!string(i);
или format
:
import std.string;
string message = format("Value of 'i' is %s.", i);
Как в D я должен использовать целое число для строки? Что-то вроде
int i = 15
string message = "Value of 'i' is " ~ toString(i); // cast(string) i - also does not work
Google дал мне ответ о том, как это сделать с танго, но я хочу версию phobos.
import std.conv;
int i = 15;
string message = "Value of 'i' is " ~ to!string(i);
или format
:
import std.string;
string message = format("Value of 'i' is %s.", i);
Используйте to
из 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);
есть также wtext и dtext-варианты witch возвращает wstring и dstring.