1、将对象序列化为二进制值,供WebBrowser传值:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
private static byte[] PostDataToBytes(Data postData) { JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); string requestJson = jsonSerializer.Serialize(postData); byte[] byteDatas = Encoding.UTF8.GetBytes(requestJson); return byteDatas; }
2、将二进制解码为字符串
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
/// <summary> /// 将字节序列解码为字符串 /// </summary> /// <param name="characters"></param> /// <returns></returns> public static string ASCIIBytes2String(byte[] bytes) { ASCIIEncoding encoding = new ASCIIEncoding(); string bytes2String = encoding.GetString(bytes)); return bytes2String.Replace("