static void Main(string[] args) { SInfo s = new SInfo(); IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(s)); Marshal.StructureToPtr(s, ptr, true); byte[] buffer = new byte[Marshal.SizeOf(s)]; Marshal.Copy(ptr, buffer, 0, Marshal.SizeOf(s)); Test test = new Test(); SInfo sinto = test.FromByteArray <SInfo>(buffer); }