Array::Clear Method
Sets a range of elements in the Array to zero, to false, or to nullptr, depending on the element type.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- array
- Type: System::Array
The Array whose elements need to be cleared.
- index
- Type: System::Int32
The starting index of the range of elements to clear.
- length
- Type: System::Int32
The number of elements to clear.
| Exception | Condition |
|---|---|
| ArgumentNullException | array is nullptr. |
| 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. |
Reference-type elements are set to nullptr. 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.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.