十进制转八进制代码如下:
//十进制转八进制
public string Dto10(int d)
{
string o = "";
if (d < 8)
{
o = d.ToString();
}
else
{
int c;
int s = 0;
int n = d;
int temp = d;
while (n >= 8)
{
s++;
n = n / 8;
}
int[] m = new int[s];
int i = 0;
do
{
c = d / 8;
m[i++] = d % 8;
d = c;
} while (c >= 8);
o = d.ToString();
for (int j = m.Length - 1; j >= 0; j--)
{
o += m[j];
}
}
return o;
}
效果如下: