MembershipProviderCollection.CopyTo(MembershipProvider[], Int32) 方法

定义

将成员资格提供程序集合复制到一维数组。Copies the membership provider collection to a one-dimensional array.

public:
 void CopyTo(cli::array <System::Web::Security::MembershipProvider ^> ^ array, int index);
public void CopyTo (System.Web.Security.MembershipProvider[] array, int index);
override this.CopyTo : System.Web.Security.MembershipProvider[] * int -> unit
Public Sub CopyTo (array As MembershipProvider(), index As Integer)

参数

array
MembershipProvider[]

一维数组,它是从 MembershipProviderCollection 复制的元素的目标。A one-dimensional array that is the destination of the elements copied from the MembershipProviderCollection. 该数组的索引必须从零开始。The array must have zero-based indexing.

index
Int32

array 中从零开始的索引,从此处开始复制。The zero-based index in array at which copying begins.

异常

arraynullarray is null.

index 小于零。index is less than zero.

array 是多维的。array is multidimensional.

-or- 源数组中的元素个数大于目标 arrayindex 到末尾的可用空间。The number of elements in the source array is greater than the available space from index to the end of the destination array.

无法自动将源数组的类型强制转换为目标 array 的类型。The type of the source array cannot be cast automatically to the type of the destination array.

示例

下面的代码示例使用CopyTo方法将的内容MembershipProviderCollection复制到MembershipProvider对象的数组中。The following code example uses the CopyTo method to copy the contents of a MembershipProviderCollection to an array of MembershipProvider objects.

MembershipProviderCollection providers = Membership.Providers;
MembershipProvider[] copiedProviders = new MembershipProvider[providers.Count];
providers.CopyTo(copiedProviders, 0);
Dim providers As MembershipProviderCollection = Membership.Providers
Dim copiedProviders(providers.Count) As MembershipProvider
providers.CopyTo(copiedProviders, 0)

注解

此方法使用ArrayList.CopyTo将角色提供程序对象复制到指定的数组。This method uses ArrayList.CopyTo to copy role provider objects to the specified array.

适用于

另请参阅