<PackageReference Include="Google.Protobuf" Version="3.34.2" />

Google.Protobuf.ByteString

public sealed class ByteString : IEnumerable<byte>, IEnumerable, IEquatable<ByteString>
Immutable array of bytes.
public static ByteString Empty { get; }

Returns an empty ByteString.

public bool IsEmpty { get; }

Returns true if this byte string is empty, false otherwise.

public byte this[int index] { get; }

Returns the byte at the given index.

public int Length { get; }

Returns the length of this ByteString in bytes.

public ReadOnlyMemory<byte> Memory { get; }

Provides read-only access to the data of this ByteString. No data is copied so this is the most efficient way of accessing.

public ReadOnlySpan<byte> Span { get; }

Provides read-only access to the data of this ByteString. No data is copied so this is the most efficient way of accessing.

public static ByteString CopyFrom(byte[] bytes)

Constructs a ByteString from the given array. The contents are copied, so further modifications to the array will not be reflected in the returned ByteString. This method can also be invoked in ByteString.CopyFrom(0xaa, 0xbb, ...) form which is primarily useful for testing.

public static ByteString CopyFrom(byte[] bytes, int offset, int count)

Constructs a ByteString from a portion of a byte array.

public static ByteString CopyFrom(ReadOnlySpan<byte> bytes)

Constructs a ByteString from a read only span. The contents are copied, so further modifications to the span will not be reflected in the returned ByteString.

public static ByteString CopyFrom(string text, Encoding encoding)

Creates a new ByteString by encoding the specified text with the given encoding.

public static ByteString CopyFromUtf8(string text)

Creates a new ByteString by encoding the specified text in UTF-8.

public static ByteString FromBase64(string bytes)

Constructs a ByteString from the Base64 Encoded String.

public static ByteString FromStream(Stream stream)

Constructs a ByteString from data in the given stream, synchronously.

public static Task<ByteString> FromStreamAsync(Stream stream, CancellationToken cancellationToken = default)

Constructs a ByteString from data in the given stream, asynchronously.

public static bool op_Equality(ByteString lhs, ByteString rhs)

Compares two byte strings for equality.

public static bool op_Inequality(ByteString lhs, ByteString rhs)

Compares two byte strings for inequality.

public void CopyTo(byte[] array, int position)

Copies the entire byte array to the destination array provided at the offset specified.

Creates a CodedInputStream from this ByteString's data.

public bool Equals(ByteString other)

Compares this byte string with another.

public IEnumerator<byte> GetEnumerator()

Returns an iterator over the bytes in this ByteString.

public string ToBase64()

Converts this ByteString into a standard base64 representation.

public byte[] ToByteArray()

Converts this ByteString into a byte array.

public string ToString(Encoding encoding)

Converts this ByteString into a string by applying the given encoding.

public string ToStringUtf8()

Converts this ByteString into a string by applying the UTF-8 encoding.

public void WriteTo(Stream outputStream)

Writes the entire byte array to the provided stream