public void H5DiterateTest1() { int[] buf = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; IntPtr count_ptr = Marshal.AllocHGlobal(sizeof(int)); Marshal.WriteInt32(count_ptr, 0); hsize_t[] dims = { 10 }; hid_t space = H5S.create_simple(1, dims, null); Assert.IsTrue(space >= 0); Assert.IsTrue(H5S.select_all(space) >= 0); GCHandle buf_hnd = GCHandle.Alloc(buf, GCHandleType.Pinned); H5D.operator_t cb = DelegateMethod; Assert.IsTrue( H5D.iterate(buf_hnd.AddrOfPinnedObject(), H5T.NATIVE_INT, space, cb, count_ptr) >= 0); buf_hnd.Free(); int count = Marshal.ReadInt32(count_ptr); // expect the sum of the buffer elements Assert.IsTrue(count == 45); Assert.IsTrue(H5S.close(space) >= 0); Marshal.FreeHGlobal(count_ptr); }