vc++传结构体到C#中,为啥C#中的值 老是一样的!!
vc+++
struct Point
{
int x,y;
int _x,_y;
int width,height;
int frameSum;
float length;
char pictureName[50];
bool Success;
int order;
float area;
int X,Y;
} ;
C#
[StructLayout(LayoutKind.Sequential)]
public struct Point
{
int star_x,star_y;
int end_x,end_y;
int width,height;
int frameSum;
float length;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 50)] // 声明一个字符数组,大小为50
char[] pictureName;
bool Success;
int order;
float area;
int X,Y;
};
VC++
char recvstr[sizeof(Point)];
memcpy(recvstr,&defectpoint,sizeof(Point));
send(sockClient,recvstr,sizeof(Point),0);
C#
buffer = new byte[1024];
ns.Read(buffer, 0, buffer.Length);
Pointdefepoint = (Point)BytesToStruct(buffer, typeof(Point));
帮帮忙 在线等啊。