Dで整数を文字列にキャストするにはどうすればよいですか? 何かのようなもの
int i = 15
string message = "Value of 'i' is " ~ toString(i); // cast(string) i - also does not work
グーグルはタンゴでそれを行う方法についての答えを私にもたらしましたが、私はフォボスバージョンが欲しいです.
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);
std.convto
から使用:
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);
wstring と dstring を返す wtext と dtext バリアントもあります。