PeterO.ArrayWriter
## PeterO.ArrayWriter
public sealed class ArrayWriter :
PeterO.IByteWriter,
PeterO.IWriter
An array of bytes that grows as needed.
Member Summary
[Clear()](#Clear)- Offers a fast way to reset the length of the array writer’s data to 0.[ToArray()](#ToArray)- Generates an array of all bytes written so far to it.[Write(byte[], int, int)](#Write_byte_int_int)- Writes a series of bytes to the array.[WriteByte(int)](#WriteByte_int)- Writes an 8-bit byte to the array.
public ArrayWriter(
int initialSize);
Initializes a new instance of the PeterO.ArrayWriter class.
Parameters:
- initialSize: The initial size of the array writer’s backing store.
public ArrayWriter();
Initializes a new instance of the PeterO.ArrayWriter class with a default backing store size of 16.
public void Clear();
Offers a fast way to reset the length of the array writer’s data to 0.
public byte[] ToArray();
Generates an array of all bytes written so far to it.
Return Value:
A byte array.
public sealed void Write(
byte[] src,
int offset,
int length);
Writes a series of bytes to the array.
Parameters:
-
src: Byte array containing the data to write.
-
offset: An index starting at 0 showing where the desired portion of src begins.
-
length: The number of elements in the desired portion of src (but not more than src ‘s length).
Exceptions:
-
System.ArgumentNullException: The parameter src is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than src ‘s length, or src ‘s length minus offset is less than length .
public sealed void WriteByte(
int byteValue);
Writes an 8-bit byte to the array.
Parameters:
- byteValue: An integer containing the byte to write. Only the lower 8 bits of this value will be used.