以下代碼將一個(gè)整數(shù)(包括0)轉(zhuǎn)化為字符串類型(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; |
|