参数为结构变量

public static TestStruct FromBinaryReaderBlock(BinaryReader br)
{    //Read byte array    byte[] buff = br.ReadBytes(Marshal.SizeOf(typeof(TestStruct)));   
 //Make sure that the Garbage Collector doesn't move our buffer    
 GCHandle handle = GCHandle.Alloc(buff, GCHandleType.Pinned);   
 //Marshal the bytes    TestStruct s =       (TestStruct)Marshal.PtrToStructure(handle.AddrOfPinnedObject(),      typeof(TestStruct));   
 handle.Free();//Give control of the buffer back to the GC    
 return s;
}

想用这段程序,但结构是直接指定的,如果结构是个变量应该怎么写?
跃然一笑
浏览 290回答 1
1回答

慕后森

什么意思,没看懂,你的意思是想:TestStruct ts=FromBinaryReaderBlock(br);想这么用?
打开App,查看更多内容
随时随地看视频慕课网APP