.net c# 将十进制转十六进制代码
//十进制转十六进制
public string Dto16(int d)
{
string x = "";
if (d < 16)
{
x = ChangValue(d);
}
else
{
int c;
int s = 0;
int n = d;
int temp = d;
while (n >= 16)
{
s++;
n = n / 16;
}
string[] m = new string[s];
int i = 0;
do
{
c = d / 16;
m[i++] = ChangValue(d % 16);//判断是否大于10,如果大于10,则转换为A~F的格式
d = c;
} while (c >= 16);
x = ChangValue(d);
for (int j = m.Length - 1; j >= 0; j--)
{
x += m[j];
}
}
return x;
}
效果如下: