Beispiel #1
0
        public T this[int index]
        {
            //实现索引器的get方法
            get
            {
                if (!IsValidIndex(index))
                {
                    throw new IndexOutOfRangeException();
                }
                return(UObject.WrapObject <T>(Marshal.ReadIntPtr(FScriptArray.GetData(ref InterArray) + IntPtr.Size * index)));
            }

            //实现索引器的set方法
            set
            {
                if (!IsValidIndex(index))
                {
                    throw new IndexOutOfRangeException();
                }

                Marshal.WriteIntPtr(FScriptArray.GetData(ref InterArray) + IntPtr.Size * index, value != null? value._this.Get():IntPtr.Zero);
            }
        }
Beispiel #2
0
        public T this[int index]
        {
            //实现索引器的get方法
            get
            {
                if (!IsValidIndex(index))
                {
                    throw new IndexOutOfRangeException();
                }
                return((T)Marshal.PtrToStructure(FScriptArray.GetData(ref InterArray) + Marshal.SizeOf(typeof(T)) * index, typeof(T)));
            }

            //实现索引器的set方法
            set
            {
                if (!IsValidIndex(index))
                {
                    throw new IndexOutOfRangeException();
                }

                Marshal.StructureToPtr(value, FScriptArray.GetData(ref InterArray) + Marshal.SizeOf(typeof(T)) * index, false);
            }
        }