docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class BinaryWriterExtensions

    Extensions for the BinaryWriter class. These extensions provide methods for writing strings and byte arrays to a binary writer.

    Inheritance
    object
    BinaryWriterExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)