Class BinaryWriterExtensions
Extensions for the BinaryWriter class. These extensions provide methods for writing strings and byte arrays to a binary writer.
Inherited Members
Namespace: UnityEngine.TestTools.Graphics
Assembly: UnityEngine.TestTools.Graphics.dll
Syntax
public static class BinaryWriterExtensions
Methods
WriteBytes(BinaryWriter, byte[])
Writes a byte array to the binary writer. The byte array is written as a length-prefixed array. The length of the array is written as an integer, followed by the byte array itself. If the byte array is null, -1 is written as the length.
Declaration
public static void WriteBytes(this BinaryWriter writer, byte[] value)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | The binary writer to write the byte array to. |
| byte[] | value | The byte array to write. |
WriteString(BinaryWriter, string, Encoding)
Writes a string to the binary writer. The string is written as a length-prefixed string. The length of the string is written as an integer, followed by the string itself. If the string is null, -1 is written as the length.
Declaration
public static void WriteString(this BinaryWriter writer, string value, Encoding encoding = null)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | The binary writer to write the string to. |
| string | value | The string to write. |
| Encoding | encoding | The encoding to use for the string. |