Struct KeyBytes
Wraps a byte array and provides equality comparison and hash code calculation. Designed to be used as a key in dictionaries.
Implements
Namespace: Libplanet.Store.Trie
Assembly: Libplanet.Store.dll
Syntax
public readonly struct KeyBytes
Constructors
| Improve this Doc View SourceKeyBytes(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<System.Byte> | bytes | An immutable byte array to wrap. |
KeyBytes(Byte[])
Creates a new KeyBytes instance from the given byte array.
Declaration
public KeyBytes(params byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | A mutable byte array to wrap. |
KeyBytes(String)
Declaration
public KeyBytes(string str)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | The key langword_csharp_string to encode into bytes. |
Fields
| Improve this Doc View SourceEncoding
The default
Declaration
public static readonly Encoding Encoding
Field Value
Type | Description |
---|---|
Encoding |
Properties
| Improve this Doc View SourceByteArray
The immutable array of bytes.
Declaration
public readonly ImmutableArray<byte> ByteArray { get; }
Property Value
Type | Description |
---|---|
ImmutableArray<System.Byte> |
Hex
The hexadecimal string representation of the byte array.
Declaration
public readonly string Hex { get; }
Property Value
Type | Description |
---|---|
System.String |
Length
The length of the byte array.
Declaration
public readonly int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceEquals(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 |
---|---|
System.Boolean |
Equals(Nullable<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 |
---|---|---|
System.Nullable<System.Object> | obj |
Returns
Type | Description |
---|---|
System.Boolean |
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 |
---|---|---|
System.String | hex | A hexadecimal string which encodes bytes. |
Returns
Type | Description |
---|---|
KeyBytes | A new KeyBytes instance. |
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 |
---|---|
System.Int32 |
ToByteArray()
Converts to a mutable byte array.
Declaration
public readonly byte[] ToByteArray()
Returns
Type | Description |
---|---|
System.Byte[] | A new copy of mutable byte array. |
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 |
---|---|
System.String |
Operators
| Improve this Doc View SourceEquality(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 |
---|---|
System.Boolean | true if two values equal; otherwise false. |
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 |
---|---|
System.Boolean | false if two values equal; otherwise true. |