System.Collections.Stack.CopyTo C# (CSharp) Méthode

CopyTo() public méthode

public CopyTo ( Array array, int index ) : void
array System.Array
index int
Résultat void
        public virtual void CopyTo(Array array, int index)
        {
            if (array == null)
                throw new ArgumentNullException(nameof(array));
            if (array.Rank != 1)
                throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, nameof(array));
            if (index < 0)
                throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum);
            if (array.Length - index < _size)
                throw new ArgumentException(SR.Argument_InvalidOffLen);
            Contract.EndContractBlock();

            int i = 0;
            object[] objArray = array as object[];
            if (objArray != null)
            {
                while (i < _size)
                {
                    objArray[i + index] = _array[_size - i - 1];
                    i++;
                }
            }
            else
            {
                while (i < _size)
                {
                    array.SetValue(_array[_size - i - 1], i + index);
                    i++;
                }
            }
        }

Same methods

Stack::CopyTo ( System array, int index ) : void

Usage Example

 static int CopyTo(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         System.Collections.Stack obj  = (System.Collections.Stack)ToLua.CheckObject(L, 1, typeof(System.Collections.Stack));
         System.Array             arg0 = (System.Array)ToLua.CheckObject(L, 2, typeof(System.Array));
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         obj.CopyTo(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
All Usage Examples Of System.Collections.Stack::CopyTo