struct ABC
{ short a;
int b;
int c;
}
byte byte_abc[100];
ABC [] abc = new ABC[10];
abc[0]= (ABC)BytesToStruct(byte_abc, Marshal.SizeOf(abc), abc.GetType());
继续计算abc[1]时,就不能直接利用上述方法了。
请问有什么办法直接利用byte [] abc,而不需要再构建一个新的byte数组作为参量?
struct ABC
{ short a;
int b;
int c;
}
byte byte_abc[100];
ABC [] abc = new ABC[10];
abc[0]= (ABC)BytesToStruct(byte_abc, Marshal.SizeOf(abc), abc.GetType());
继续计算abc[1]时,就不能直接利用上述方法了。
请问有什么办法直接利用byte [] abc,而不需要再构建一个新的byte数组作为参量?
你想表达的意思完全没看懂,你是想吧byte_abc数组变成ABC结构么??
直接这样啊
ABC tmp=new ABC();
tmp = (ABC)BytesToStruct(byte_abc, Marshal.SizeOf(tmp), ABC.GetType());