網站運營seo文章大全提供全面的站長運營經驗及seo技術!string strtohex(string str)
{
string strtemp = "";
 if(str="")
 return "";
byte[] btemp = system.text.encoding.default.getbytes(str);
for(int i = 0;i<btemp.length;i++)
{
strtemp += btemp[i].tostring("x");
}
return strtemp;
}
下面摘自csdn,byte[] 轉 string 很快,沒有測試
char[] hexdigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; 
string tohexstring(byte[] bytes) 
{ 
char[] chars = new char[bytes.length * 2]; 
for (int i = 0; i < bytes.length; i++) 
{ 
int b = bytes[i]; 
chars[i * 2] = hexdigits[b >> 4]; 
chars[i * 2 + 1] = hexdigits[b & 0xf]; 
} 
return new string(chars); 
}