当前位置: 首页>>代码示例>>C#>>正文


C# Object.CopyTo方法代码示例

本文整理汇总了C#中Object.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# Object.CopyTo方法的具体用法?C# Object.CopyTo怎么用?C# Object.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Object的用法示例。


在下文中一共展示了Object.CopyTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderStaticPreview

    public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
    {
        Object[] assets = subAssets;

        Projectile child = this.target as Projectile;
        if ( child.ProjectilePrefab != null )
        {
            assets = new Object[subAssets.Length+1];
            subAssets.CopyTo(assets,0);
            assets[subAssets.Length-1] = child.ProjectilePrefab;
        }

        return base.RenderStaticPreview (assetPath, assets, width, height);
    }
开发者ID:GhostTap,项目名称:SolarStrike,代码行数:14,代码来源:ProjectileEditor.cs

示例2: InsertRange

        // Inserts the elements of the given collection at a given index. If
        // required, the capacity of the list is increased to twice the previous
        // capacity or the new size, whichever is larger.  Ranges may be added
        // to the end of the list by setting index to the ArrayList's size.
        //
        public virtual void InsertRange(int index, ICollection c)
        {
            if (c == null)
                throw new ArgumentNullException(nameof(c), SR.ArgumentNull_Collection);
            if (index < 0 || index > _size) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
            //Contract.Ensures(Count == Contract.OldValue(Count) + c.Count);
            Contract.EndContractBlock();

            int count = c.Count;
            if (count > 0)
            {
                EnsureCapacity(_size + count);
                // shift existing items
                if (index < _size)
                {
                    Array.Copy(_items, index, _items, index + count, _size - index);
                }

                Object[] itemsToInsert = new Object[count];
                c.CopyTo(itemsToInsert, 0);
                itemsToInsert.CopyTo(_items, index);
                _size += count;
                _version++;
            }
        }
开发者ID:eerhardt,项目名称:corefx,代码行数:30,代码来源:ArrayList.cs


注:本文中的Object.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。