Struct KeyBytes
Wraps a byte array and provides equality comparison and hash code calculation. Designed to be used as a key in dictionaries.
Implements
Inherited Members
Namespace: Libplanet.Store.Trie
Assembly: Libplanet.Store.dll
Syntax
public readonly struct KeyBytes : IEquatable<KeyBytes>
Constructors
| Improve this Doc View SourceKeyBytes(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(in ImmutableArray<Byte>)
Creates a new KeyBytes instance from the given byte array.
Declaration
public KeyBytes(in ImmutableArray<byte> bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Immutable.ImmutableArray<System.Byte> | bytes | An immutable byte array to wrap. |
KeyBytes(String)
Declaration
public KeyBytes(string str)
Parameters
Type | Name | Description |
---|---|---|
String | str | The key langword_csharp_string to encode into bytes. |
Fields
| Improve this Doc View SourceEncoding
The default System.Text.Encoding, which is System.Text.Encoding.UTF8, to use when creating an instance from a langword_csharp_string.
Declaration
public static readonly Encoding Encoding
Field Value
Type | Description |
---|---|
System.Text.Encoding |
Properties
| Improve this Doc View SourceByteArray
The immutable array of bytes.
Declaration
public readonly ImmutableArray<byte> ByteArray { get; }
Property Value
Type | Description |
---|---|
System.Collections.Immutable.ImmutableArray<System.Byte> |
Hex
The hexadecimal string representation of the byte array.
Declaration
public readonly string Hex { get; }
Property Value
Type | Description |
---|---|
String |
Length
The length of the byte array.
Declaration
public readonly int Length { get; }
Property Value
Type | Description |
---|---|
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(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 |
---|---|
System.Boolean |
Overrides
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 |
---|---|
System.ArgumentNullException | Thrown when the given |
ArgumentOutOfRangeException | Thrown when the length of the given
|
FormatException | Thrown when the given |
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
| Improve this Doc View SourceToByteArray()
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 |
---|---|
String |
Overrides
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. |