本文整理汇总了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);
}
示例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++;
}
}