代码
static string TransToString(int value)
{
int step = 1000000000;
char[] results = new char[10];
int index = 0;
if (value < 0)
{
results[index++] = '-';
value = 0 - value;
}
while (value / step == 0)
step /= 10;
while (step!=0&&value / step >= 0)
{
if (value / step > 0)
{
results[index++] = (char)('0' + value / step);
value = value % step;
step /= 10;
}
else if (value / step == 0)
{
results[index++] = '0';
step /= 10;
}
}
return new string(results, 0, index);
}
{
int step = 1000000000;
char[] results = new char[10];
int index = 0;
if (value < 0)
{
results[index++] = '-';
value = 0 - value;
}
while (value / step == 0)
step /= 10;
while (step!=0&&value / step >= 0)
{
if (value / step > 0)
{
results[index++] = (char)('0' + value / step);
value = value % step;
step /= 10;
}
else if (value / step == 0)
{
results[index++] = '0';
step /= 10;
}
}
return new string(results, 0, index);
}