public static string Str2Hex(string s)
{
string result = string.Empty;
byte[] arrByte = System.Text.Encoding.GetEncoding(“GB2312”).GetBytes(s);
for (int i = 0; i < arrByte.Length; i++)
{
result += “0x” + System.Convert.ToString(arrByte[i], 16).ToUpper() + “,”; //Convert.ToString(byte, 16)把byte转化成十六进制string
}
return result;
}