docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class BinaryReaderExtensions

    Extensions for the BinaryReader class. These extensions provide methods for reading strings and byte arrays from a binary reader.

    Inheritance
    object
    BinaryReaderExtensions
    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 BinaryReaderExtensions

    Methods

    GetBytes(BinaryReader)

    Reads a byte array from the binary reader. The byte array is read as a length-prefixed array. The length of the array is read as an integer, followed by the byte array itself.

    Declaration
    public static byte[] GetBytes(this BinaryReader reader)
    Parameters
    Type Name Description
    BinaryReader reader

    The binary reader to read the byte array from.

    Returns
    Type Description
    byte[]

    The byte array read from the binary reader. If the length is -1, null is returned.

    GetString(BinaryReader, Encoding)

    Reads a string from the binary reader.

    Declaration
    public static string GetString(this BinaryReader reader, Encoding encoding = null)
    Parameters
    Type Name Description
    BinaryReader reader

    The binary reader to read the string from.

    Encoding encoding

    The encoding to use for the string.

    Returns
    Type Description
    string

    The string read from the binary reader. If the length is -1, null is returned.

    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)