static void testConvertor() { var ts = new TestStructure { S = "tstsfsdfs", I = 213123, DT = DateTime.Now }; var bytTemp = Convertor.Object2Bytes(ts); Console.WriteLine("数组长度:" + bytTemp.Length); var tsB = (TestStructure)Convertor.Bytes2Object(bytTemp, typeof(TestStructure)); Console.WriteLine(tsB.ToString()); var b = new macbook { name = "mac10", price = 10000 }; var buff = Convertor.Object2Bytes(b); var o = (book)Convertor.Bytes2Object(buff, typeof(book)); var buff2 = Convertor.ObjectToBytes(b); var obj = Convertor.BytesToObject(buff2); Console.ReadLine(); }