SweetScape Knowledgebase KB1016: How do I convert an int to a string?
The easiest way to convert an integer (short, int, int64, etc.) to a string
is to use the SPrintf function. For example:
ushort a = 16;
string s;
SPrintf( s, "%d", (int)a );
After this code is executed, the variable 's' will contain the string '16'.
Remember when using the SPrintf function that
the arguments passed to the function must match the format string (e.g. when using
'%d' you must pass an int, not a short).
Back to knowledgebase index
Back to main support page
|