Codecrete.SwissQRBill.WindowsTest.EmfMetaInfo.ByteArrayToStructure C# (CSharp) Method

ByteArrayToStructure() static private method

static private ByteArrayToStructure ( Array bytes, int offset ) : T
bytes Array
offset int
return T
        static T ByteArrayToStructure<T>(byte[] bytes, int offset) where T : struct
        {
            var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
            try
            {
                return Marshal.PtrToStructure<T>(IntPtr.Add(handle.AddrOfPinnedObject(), offset));
            }
            finally
            {
                handle.Free();
            }
        }