将.NET对象转换为(字节*)
有没有办法将将.NET对象转换为(字节*),.net,casting,.net,Casting,有没有办法将系统对象强制转换为字节*?,只需将其强制转换为字节数组即可。,只需将其强制转换为字节数组即可。只需使用: byte[] b = (byte[]) myobj; 只需使用: byte[] b = (byte[]) myobj; 像…这样的怎么样 BinaryFormatter bf = new BinaryFormatter(); System.IO.MemoryStream ms = new System.IO.MemoryStream(1024); Object1 blah
系统对象
强制转换为字节*
?,只需将其强制转换为字节数组即可。,只需将其强制转换为字节数组即可。只需使用:
byte[] b = (byte[]) myobj;
只需使用:
byte[] b = (byte[]) myobj;
像…这样的怎么样
BinaryFormatter bf = new BinaryFormatter();
System.IO.MemoryStream ms = new System.IO.MemoryStream(1024);
Object1 blah = new Object1("Hello");
bf.Serialize(ms, blah);
byte[] bytes = ms.GetBuffer();
像…这样的怎么样
BinaryFormatter bf = new BinaryFormatter();
System.IO.MemoryStream ms = new System.IO.MemoryStream(1024);
Object1 blah = new Object1("Hello");
bf.Serialize(ms, blah);
byte[] bytes = ms.GetBuffer();
好的,我找到了解决方案:
(byte*)(int)someObject
好的,我找到了解决方案:
(byte*)(int)someObject
我需要转换到不安全的指针。我做了一个变通办法。通过函数传递int。我可以轻松地将byte*转换为int,并将int转换为byte*。但问题仍然在这里。我需要转换到不安全的指针。我做了一个变通办法。通过函数传递int。我可以轻松地将byte*转换为int,并将int转换为byte*。但问题仍然在这里。如果某个对象大于int怎么办?在64位模式下不工作。指针大于整数。如果某个对象大于整数怎么办?在64位模式下不工作。指针大于整数。