> Thanks, but maybe I don't explain it very well. I need to read the > values written by another app, that is Unmanaged(C++,VB), in a socket. I > can't alter the way the data is written, because is another app, but I > know the structure of the data, just like:
> (C++) (C#) > struct aMsg struct aMsg > { { > DWORD a; int a; > DWORD b; int b; > DWORD c; int c; > } } > Then, the C++ structure is written in the socket, and then I receive the > byte[] in C#. I want to do something like (so simple): > byte[] received; > aMsg myMsg=(aMsg)received; First, check to ensure the proper length of the data. Then write code like the following: MemoryStream ms = new MemoryStream(received); BinaryReader br = new BinaryReader(ms); myMsg.a = br.ReadInt32(); myMsg.b = br.ReadInt32(); myMsg.c = br.ReadInt32(); What I typically do is define a struct with FromArray() and ToArray() methods that contain code like the above. Then you can do the following: aMsg myMsg = new aMsg(); aMsg.FromArray(received); HTH, -- Steve Johnson 3t Systems You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.