Array.Initialize 方法

定义

通过调用值类型的无参数构造函数,初始化值类型 Array 的每一个元素。Initializes every element of the value-type Array by calling the parameterless constructor of the value type.

public:
 void Initialize();
public void Initialize ();
member this.Initialize : unit -> unit
Public Sub Initialize ()

注解

此方法旨在帮助编译器支持值类型数组;大多数用户不需要此方法。This method is designed to help compilers support value-type arrays; most users do not need this method. 不能对引用类型数组使用。It must not be used on reference-type arrays.

如果 Array 不是 Array 值类型,或者如果值类型没有无参数的构造函数,则不会修改 ArrayIf the Array is not a value-type Array or if the value type does not have a parameterless constructor, the Array is not modified.

值类型 Array 可以有任何下限和任意数量的维度。The value-type Array can have any lower bound and any number of dimensions.

此方法是一个 O (n)操作,其中 nLength的。This method is an O(n) operation, where n is Length.

注意

只能对具有构造函数的值类型使用此方法;但不具有构造函数的本机C#值类型。You can use this method only on value types that have constructors; however, value types that are native to C# do not have constructors.

适用于