Show / Hide Table of Contents

Struct KeyBytes

Wraps a byte array and provides equality comparison and hash code calculation. Designed to be used as a key in dictionaries.

Implements
IEquatable<KeyBytes>
IEquatable<ImmutableArray<Byte>>
IEquatable<Byte[]>
Inherited Members
Object.Equals(Object, Object)
Object.GetType()
Object.ReferenceEquals(Object, Object)
Namespace: Libplanet.Store.Trie
Assembly: Libplanet.dll
Syntax
public readonly struct KeyBytes : IEquatable<KeyBytes>, IEquatable<ImmutableArray<byte>>, IEquatable<byte[]>

Constructors

| Improve this Doc View Source

KeyBytes(Byte[])

Creates a new KeyBytes instance from the given byte array.

Declaration
public KeyBytes(params byte[] bytes)
Parameters
Type Name Description
Byte[] bytes

A mutable byte array to wrap.

| Improve this Doc View Source

KeyBytes(in ImmutableArray<Byte>)

Creates a new KeyBytes instance from the given byte array.

Declaration
public KeyBytes(in ImmutableArray<byte> bytes)
Parameters
Type Name Description
ImmutableArray<Byte> bytes

An immutable byte array to wrap.

| Improve this Doc View Source

KeyBytes(String, Encoding)

Creates a new KeyBytes instance from the given string.

Declaration
public KeyBytes(string string, Encoding encoding)
Parameters
Type Name Description
String string

A key string. This is encoded to bytes.

Encoding encoding

The text encoding used for the key string.

Properties

| Improve this Doc View Source

ByteArray

The immutable array of bytes.

Declaration
public readonly ImmutableArray<byte> ByteArray { get; }
Property Value
Type Description
ImmutableArray<Byte>
| Improve this Doc View Source

Hex

The hexadecimal string representation of the byte array.

Declaration
public readonly string Hex { get; }
Property Value
Type Description
String
| Improve this Doc View Source

Length

The length of the byte array.

Declaration
public readonly int Length { get; }
Property Value
Type Description
Int32

Methods

| Improve this Doc View Source

Equals(KeyBytes)

Wraps a byte array and provides equality comparison and hash code calculation. Designed to be used as a key in dictionaries.

Declaration
public readonly bool Equals(KeyBytes other)
Parameters
Type Name Description
KeyBytes other
Returns
Type Description
Boolean
| Improve this Doc View Source

Equals(Byte[])

Wraps a byte array and provides equality comparison and hash code calculation. Designed to be used as a key in dictionaries.

Declaration
public readonly bool Equals(byte[] other)
Parameters
Type Name Description
Byte[] other
Returns
Type Description
Boolean
| Improve this Doc View Source

Equals(ImmutableArray<Byte>)

Wraps a byte array and provides equality comparison and hash code calculation. Designed to be used as a key in dictionaries.

Declaration
public readonly bool Equals(ImmutableArray<byte> other)
Parameters
Type Name Description
ImmutableArray<Byte> other
Returns
Type Description
Boolean
| Improve this Doc View Source

Equals(Object)

Wraps a byte array and provides equality comparison and hash code calculation. Designed to be used as a key in dictionaries.

Declaration
public override readonly bool Equals(object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean
Overrides
ValueType.Equals(Object)
| Improve this Doc View Source

FromHex(String)

Parses the given hexadecimal string as bytes and returns a new KeyBytes instance.

Declaration
public static KeyBytes FromHex(string hex)
Parameters
Type Name Description
String hex

A hexadecimal string which encodes bytes.

Returns
Type Description
KeyBytes

A new KeyBytes instance.

Exceptions
Type Condition
ArgumentNullException

Thrown when the given hex string is null.

ArgumentOutOfRangeException

Thrown when the length of the given hex string is an odd number.

FormatException

Thrown when the given hex string is not a valid hexadecimal string.

| Improve this Doc View Source

GetHashCode()

Wraps a byte array and provides equality comparison and hash code calculation. Designed to be used as a key in dictionaries.

Declaration
public override readonly int GetHashCode()
Returns
Type Description
Int32
Overrides
ValueType.GetHashCode()
| Improve this Doc View Source

ToByteArray()

Converts to a mutable byte array.

Declaration
public readonly byte[] ToByteArray()
Returns
Type Description
Byte[]

A new copy of mutable byte array.

| Improve this Doc View Source

ToString()

Wraps a byte array and provides equality comparison and hash code calculation. Designed to be used as a key in dictionaries.

Declaration
public override readonly string ToString()
Returns
Type Description
String
Overrides
ValueType.ToString()

Operators

| Improve this Doc View Source

Equality(KeyBytes, KeyBytes)

Compares two KeyBytes values.

Declaration
public static bool operator ==(KeyBytes left, KeyBytes right)
Parameters
Type Name Description
KeyBytes left

An operand.

KeyBytes right

Another operand.

Returns
Type Description
Boolean

true if two values equal; otherwise false.

| Improve this Doc View Source

Inequality(KeyBytes, KeyBytes)

Compares two KeyBytes values.

Declaration
public static bool operator !=(KeyBytes left, KeyBytes right)
Parameters
Type Name Description
KeyBytes left

An operand.

KeyBytes right

Another operand.

Returns
Type Description
Boolean

false if two values equal; otherwise true.

Implements

System.IEquatable<T>
System.IEquatable<T>
System.IEquatable<T>
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium