public IpcUserRights(UserRights userRights) : this() { user = new IpcUser(); user.userType = userRights.UserIdType; user.userID = userRights.UserId; cRights = (uint)userRights.Rights.Count; // Allocate memory for the right string array rgwszRights = Marshal.AllocHGlobal(userRights.Rights.Count * Marshal.SizeOf(typeof(IntPtr))); // go to the first right string entry IntPtr currentRightPtr = rgwszRights; foreach (string right in userRights.Rights) { // the right string itself IntPtr RightStringPtr = Marshal.StringToHGlobalUni(right); // assign the pointer Marshal.WriteIntPtr(currentRightPtr, 0, RightStringPtr); // go to the next right string entry currentRightPtr = new IntPtr(currentRightPtr.ToInt64() + Marshal.SizeOf(typeof(IntPtr))); } }