Share via


Clear Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Sets a range of elements in the Array to zero, to false, or to nullNothingnullptrunita null reference (Nothing in Visual Basic), depending on the element type.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Shared Sub Clear ( _
    array As Array, _
    index As Integer, _
    length As Integer _
)
public static void Clear(
    Array array,
    int index,
    int length
)
public:
static void Clear(
    Array^ array, 
    int index, 
    int length
)
static member Clear : 
        array:Array * 
        index:int * 
        length:int -> unit 
public static function Clear(
    array : Array, 
    index : int, 
    length : int
)

Parameters

Exceptions

Exception Condition
ArgumentNullException

array is null Nothing nullptr unit a null reference (Nothing in Visual Basic) .

IndexOutOfRangeException

index is less than the lower bound of array.

-or-

length is less than zero.

-or-

The sum of index and length is greater than the size of the Array.

Remarks

Reference-type elements are set to null Nothing nullptr unit a null reference (Nothing in Visual Basic) . Boolean-type elements are set to false. Other value-type elements are set to zero.

The range of cleared elements wrap from row to row in a multi-dimensional array.

This method only clears the values of the elements; it does not delete the elements themselves. An Array has a fixed size; therefore, elements cannot be added or removed.

This method is an O(n) operation, where n is length.

.NET Framework Security

See Also

Reference

Array Class

System Namespace