如何在D中將整數轉換爲字符串? 喜歡的東西D中的字符串轉換整數
int i = 15
string message = "Value of 'i' is " ~ toString(i); // cast(string) i - also does not work
谷歌給我帶來了關於如何與探戈做的答案,但我要的火衛一的版本。
如何在D中將整數轉換爲字符串? 喜歡的東西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);
使用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變種女巫返回的wstring和dstring。
只是精彩:) – Trass3r