以下代码将一个整数(包括0)转化为字符串类型(string)返回:
private string IntToString( int integer) { string result = ""; int temp = integer; if (temp == 0) { result = "0"; return result;
} while (temp != 0) { // add a digit to the head of a string switch (temp % 10) { case 0: result = '0' + result; break; case 1: case 2: case 5: case 6: case 7: case 8: case 9: return result; |
|