Returns the total number of bytes in this array.
[Visual Basic] Public Shared Function ByteLength( _ ByVal array As Array _ ) As Integer [C#] public static int ByteLength( Array array ); [C++] public: static int ByteLength( Array* array ); [JScript] public static function ByteLength( array : Array ) : int;
The number of bytes in the array.
Exception Type | Condition |
---|---|
ArgumentException | If the array is not a primitive. |
ArgumentNullException | If the array is null. |
The ByteLength method gets a particular byte out of an array. The array must be an array of primitives. It essentially does the following:
return array.length * sizeof(array.UnderlyingElementType)
[C#]
int [] arr = new int [5] = {0, 1, 2, 3, 4}; Assert (arr.ByteLength == 20); for (int i = 0; i < arr.ByteLength; i++) { Console.Write (arr[i].GetByte(i)); } //this will print: //00000001000200030004