Way1:
字节数组data转换为字符串recStr:
string recStr = BitConverter.ToString(data, 0, len);
字符串replyStr转换为字节数组reply
string[] strSplit = replyStr.Split('-');
byte[] reply = new byte[strSplit.Length];
for (int i = 0; i < strSplit.Length; i++)
{
reply[i] = byte.Parse(strSplit[i], System.Globalization.NumberStyles.AllowHexSpecifier);
}
Way2:
字节数组data转换为字符串recStr:
string recStr = Encoding.ASCII.GetString(data, 0, len);
字符串recStr转字节数组after:
byte[] after = Encoding.ASCII.GetBytes(recStr);
Way3:
将字符串recStr转换为字节数组test:
byte[] test = System.Text.Encoding.Default.GetBytes(recStr);
将字节数组test转换为字符串str:
string str = System.Text.Encoding.Default.GetString(test);