Uuid96

Namespace: System · struct

Implements: IFormattable, IEquatable<Uuid96>, IComparable<Uuid96>, IEquatable<Slice>, ISliceSerializable, ISpanEncodable, ISpanFormattable, ISpanParsable<Uuid96>, IParsable<Uuid96>, IEquatable<ReadOnlySpan<byte>>

Represents a 96-bit UUID that is stored in high-endian format in the output

Constructors

Uuid96

Uuid96(uint upper32, ulong lower64)

Pack components into a 96-bit UUID

  • upper32XXXXXXXX-........-........
  • lower64........-XXXXXXXX-XXXXXXXX

Uuid96(uint upper32, long lower64)

Pack components into a 96-bit UUID

  • upper32XXXXXXXX-........-........
  • lower64........-XXXXXXXX-XXXXXXXX

Uuid96(int upper32, long lower64)

Pack components into a 96-bit UUID

  • upper32XXXXXXXX-........-........
  • lower64........-XXXXXXXX-XXXXXXXX

Uuid96(uint upper32, uint middle32, uint lower32)

Pack components into a 96-bit UUID

  • upper32XXXXXXXX-........-........
  • middle32........-XXXXXXXX-........
  • lower32........-........-XXXXXXXX

Uuid96(int upper32, int middle32, int lower32)

Pack components into a 96-bit UUID

  • upper32XXXXXXXX-........-........
  • middle32........-XXXXXXXX-........
  • lower32........-........-XXXXXXXX

Properties

Lower16

ushort Lower16 { get; }

Returns the 16 lower bits (........-........-....xxxx)

Lower32

uint Lower32 { get; }

Returns the 32 lower bits (........-........-xxxxxxxx)

Lower48

Uuid48 Lower48 { get; }

Returns the 48 lower bits (........-....xxxx-xxxxxxxx)

Lower64

ulong Lower64 { get; }

Returns the 64 lower bits (........-xxxxxxxx-xxxxxxxx)

Lower80

Uuid80 Lower80 { get; }

Returns the 80 lower bits (....xxxx-xxxxxxxx-xxxxxxxx)

Middle32

uint Middle32 { get; }

Returns the 32 middle bits (........-xxxxxxxx-........)

Upper16

ushort Upper16 { get; }

Returns the 16 upper bits (xxxx....-........-........)

Upper32

uint Upper32 { get; }

Returns the 32 upper bits (xxxxxxxx-........-........)

Upper48

Uuid48 Upper48 { get; }

Returns the 48 upper bits (xxxxxxxx-xxxx....-........)

Upper64

ulong Upper64 { get; }

Returns the 64 upper bits (xxxxxxxx-xxxxxxxx-........)

Upper80

Uuid80 Upper80 { get; }

Returns the 80 upper bits (xxxxxxxx-xxxxxxxx-xxxx....)

Methods

CompareTo

int CompareTo(Uuid96 other)

Deconstruct

void Deconstruct(out uint a, out ulong b)

Split into two fragments

  • a — xxxxxxxx-........-........
  • b — ........-xxxxxxxx-xxxxxxxx

void Deconstruct(out uint a, out uint b, out uint c)

Split into three fragments

  • a — xxxxxxxx-........-........
  • b — ........-xxxxxxxx-........
  • c — ........-........-xxxxxxxx

Equals

bool Equals(object obj)

bool Equals(Uuid96 other)

bool Equals(Slice other)

bool Equals(ReadOnlySpan<byte> other)

FromBase1024

static Uuid96 FromBase1024(string value)

Creates a Uuid80 from a string literal encoded in Base-1024

  • value — Base-1024 string literal

FromInt16

static Uuid96 FromInt16(short value)

Creates a Uuid96 from the lower 16 bits, with the upper 80 bits all set to 0

  • value — 16 lower bits (.........-........-....xxxx)

FromInt32

static Uuid96 FromInt32(int value)

Creates a Uuid96 from the lower 32 bits, with the upper 64 bits all set to 0

  • value — 32 lower bits (.........-........-xxxxxxxx)

FromInt64

static Uuid96 FromInt64(long value)

Creates a Uuid96 from the lower 64 bits, with the upper 32 bits all set to 0

  • value — 64 lower bits (.........-xxxxxxxx-xxxxxxxx)

FromLower16

static Uuid96 FromLower16(ushort value)

Creates a Uuid96 from the lower 16 bits, with the upper 80 bits all set to 0

  • value — 16 lower bits (.........-........-....xxxx)

FromLower32

static Uuid96 FromLower32(uint value)

Creates a Uuid96 from the lower 32 bits, with the upper 64 bits all set to 0

  • value — 32 lower bits (.........-........-xxxxxxxx)

FromLower48

static Uuid96 FromLower48(ulong value)

Creates a Uuid96 from the lower 32 bits, with the upper 64 bits all set to 0

  • value — 48 lower bits (.........-....xxxx-xxxxxxxx)

FromLower64

static Uuid96 FromLower64(ulong value)

Creates a Uuid96 from the lower 64 bits, with the upper 32 bits all set to 0

  • value — 64 lower bits (.........-xxxxxxxx-xxxxxxxx)

FromLower80

static Uuid96 FromLower80(Uuid80 value)

Creates a Uuid96 from the lower 80 bits, with the upper 16 bits all set to 0

  • value — 80 lower bits (.....xxxx-xxxxxxxx-xxxxxxxx)

FromLower96

static Uuid96 FromLower96(Uuid128 value)

Creates a Uuid96 from the lower 96 bits of a Uuid128

  • value — Only the 96 lower bits will be used (........-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

FromUInt16

static Uuid96 FromUInt16(ushort value)

Creates a Uuid96 from the lower 16 bits, with the upper 80 bits all set to 0

  • value — 16 lower bits (.........-........-....xxxx)

FromUInt32

static Uuid96 FromUInt32(uint value)

Creates a Uuid96 from the lower 32 bits, with the upper 64 bits all set to 0

  • value — 32 lower bits (.........-........-xxxxxxxx)

FromUInt48

static Uuid96 FromUInt48(ulong value)

Creates a Uuid96 from the lower 48 bits, with the upper 64 bits all set to 0

  • value — 48 lower bits (.........-....xxxx-xxxxxxxx)

FromUInt64

static Uuid96 FromUInt64(ulong value)

Creates a Uuid96 from the lower 64 bits, with the upper 32 bits all set to 0

  • value — 64 lower bits (.........-xxxxxxxx-xxxxxxxx)

FromUpper16Lower80

static Uuid96 FromUpper16Lower80(ushort hi, Uuid80 low)

Creates a Uuid96 from the upper 16-bit and lower 80-bit parts

  • hi — 16 upper bits (xxxx....-........-........)
  • low — 80 lower bits (....xxxx-xxxxxxxx-xxxxxxxx)

FromUpper32Lower64

static Uuid96 FromUpper32Lower64(uint hi, ulong low)

Creates a Uuid96 from the upper 32-bit and lower 64-bit parts

  • hi — 32 upper bits (xxxxxxxx-........-........)
  • low — 64 lower bits (........-xxxxxxxx-xxxxxxxx)

static Uuid96 FromUpper32Lower64(uint hi, Uuid64 low)

Creates a Uuid96 from the upper 32-bit and lower 64-bit parts

  • hi — 32 upper bits (xxxxxxxx-........-........)
  • low — 64 lower bits (........-xxxxxxxx-xxxxxxxx)

FromUpper32Middle32Lower32

static Uuid96 FromUpper32Middle32Lower32(uint hi, uint middle, uint low)

Creates a Uuid96 from the upper 32-bit, middle 32-bit and lower 32-bit parts

  • hi — 32 upper bits (xxxxxxxx-........-........)
  • middle — 32 middle bits (........-xxxxxxxx-........)
  • low — 32 lower bits (........-........-xxxxxxxx)

FromUpper48Lower48

static Uuid96 FromUpper48Lower48(ulong hi, ulong low)

Creates a Uuid96 from the upper 48-bit and lower 48-bit parts

  • hi — 48 upper bits (xxxxxxxx-xxxx....-........)
  • low — 48 lower bits (........-....xxxx-xxxxxxxx)

static Uuid96 FromUpper48Lower48(Uuid48 hi, Uuid48 low)

Creates a Uuid96 from the upper 48-bit and lower 48-bit parts

  • hi — 48 upper bits (xxxxxxxx-xxxx....-........)
  • low — 48 lower bits (........-....xxxx-xxxxxxxx)

FromUpper64Lower32

static Uuid96 FromUpper64Lower32(ulong hi, uint low)

Creates a Uuid96 from the upper 64-bit and lower 32-bit parts

  • hi — 64 upper bits (xxxxxxxx-xxxxxxxx-........)
  • low — 32 lower bits (........-........-xxxxxxxx)

static Uuid96 FromUpper64Lower32(Uuid64 hi, uint low)

Creates a Uuid96 from the upper 64-bit and lower 32-bit parts

  • hi — 64 upper bits (xxxxxxxx-xxxxxxxx-........)
  • low — 32 lower bits (........-........-xxxxxxxx)

FromUpper64Middle16Lower16

static Uuid96 FromUpper64Middle16Lower16(ulong hi, ushort middle, ushort low)

Creates a Uuid96 from the upper 64-bit and lower 32-bit parts

  • hi — 64 upper bits (xxxxxxxx-xxxxxxxx-........)
  • middle — 16 middle bits (........-........-xxxx....)
  • low — 16 lower bits (........-........-....xxxx)

FromUpper80Lower16

static Uuid96 FromUpper80Lower16(Uuid80 hi, ushort low)

Creates a Uuid96 from the upper 80-bit and lower 16-bit parts

  • hi — 80 upper bits (xxxxxxxx-xxxxxxxx-xxxx....)
  • low — 16 lower bits (........-........-....xxxx)

FromUpper96

static Uuid96 FromUpper96(Uuid128 value)

Creates a Uuid96 from the upper 96 bits of a Uuid128

  • value — Only the 96 upper bits will be used (xxxxxxxx-xxxx-xxxx-xxxx-xxxx........)

GetHashCode

int GetHashCode()

NewUuid

static Uuid96 NewUuid()

Generate a new random 96-bit UUID.

If you need sequential or cryptographic uuids, you should use a different generator.

Parse

static Uuid96 Parse(string input)

Parse a string representation of an Uuid96

  • input — String in either formats: "", "xxxxxxxx-xxxxxxxx-xxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxx", "{xxxxxxxx-xxxxxxxx-xxxxxxxx}", "{xxxxxxxxxxxxxxxxxxxxxxxx}"

Parsing is case-insensitive. The empty string is mapped to Uuid96.Empty.

static Uuid96 Parse(ReadOnlySpan<char> input)

Parse a string representation of an Uuid96

static Uuid96 Parse(string input, IFormatProvider provider)

Parse a string representation of an Uuid96

  • input — String in either formats: "", "badc0ffe-e0ddf00d", "badc0ffee0ddf00d", "", ""
  • provider — This argument is ignored.

Parsing is case-insensitive. The empty string is mapped to Uuid96.Empty.

static Uuid96 Parse(ReadOnlySpan<char> input, IFormatProvider provider)

Parse a string representation of an Uuid96

Read

static Uuid96 Read(byte[] value)

Reads a 96-bit UUID from slice of memory

  • value — Array of bytes that is either empty, or holds at least 12 bytes

Returns: Corresponding Uuid80 if the read is successful

If value is larger than 12 bytes, the additional bytes will be ignored.

static Uuid96 Read(Slice value)

Reads a 96-bit UUID from slice of memory

  • value — Slice of bytes that is either empty, or holds at least 12 bytes

Returns: Corresponding Uuid80 if the read is successful

If value is larger than 12 bytes, the additional bytes will be ignored.

static Uuid96 Read(ReadOnlySpan<byte> value)

Reads a 96-bit UUID from slice of memory

  • value — Span of bytes that is either empty, or holds at least 12 bytes

Returns: Corresponding Uuid80 if the read is successful

If value is larger than 12 bytes, the additional bytes will be ignored.

ToByteArray

byte[] ToByteArray()

Returns newly allocated array of bytes that represents this UUID

ToSlice

Slice ToSlice()

Returns a newly allocated Slice that represents this UUID

ToString

string ToString()

Returns a string representation of the value of this instance.

Returns: String using the format "XXXXXXXX-XXXXXXXX-XXXXXXXX", where 'X' is an upper-case hexadecimal digit

Strings returned by this method will always to 17 characters long.

string ToString(string format)

Returns a string representation of the value of this Uuid96 instance, according to the provided format specifier.

  • format — A single format specifier that indicates how to format the value of this Guid. The format parameter can be "D", "B", "X", "G", "Z" or "N". If format is null or an empty string (""), "D" is used.

Returns: The value of this Uuid96, using the specified format.

See for a description of the different formats

string ToString(string format, IFormatProvider formatProvider)

Returns a string representation of the value of this instance of the Uuid96 class, according to the provided format specifier and culture-specific format information.

  • format — A single format specifier that indicates how to format the value of this Guid. The format parameter can be "D", "N", "Z", "R", "X" or "B". If format is null or an empty string (""), "D" is used.
  • formatProvider — An object that supplies culture-specific formatting information. Only used for the "R" format.

Returns: The value of this Uuid96, using the specified format.

The D format encodes the value as three groups of hexadecimal digits, separated by a hyphen: "aaaaaaaa-bbbbbbbb-cccccccc" (26 characters).The X and N format encodes the value as a single group of 24 hexadecimal digits: "aaaaaaaabbbbbbbbcccccccc" (24 characters).The B format is equivalent to the D format, but surrounded with '{' and '}': "{aaaaaaaa-bbbbbbbb-cccccccc}" (28 characters).

TryFormat

bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider provider = null)

TryParse

static bool TryParse(string input, out Uuid96 result)

Try parsing a string representation of an Uuid96

static bool TryParse(ReadOnlySpan<char> input, out Uuid96 result)

Try parsing a string representation of an Uuid96

static bool TryParse(ReadOnlySpan<byte> utf8Text, out Uuid96 result)

Try parsing a UTF-8 string representation of an Uuid96

static bool TryParse(string input, IFormatProvider provider, out Uuid96 result)

Try parsing a string representation of an Uuid96

static bool TryParse(ReadOnlySpan<char> input, IFormatProvider provider, out Uuid96 result)

Try parsing a string representation of an Uuid96

TryRead

static bool TryRead(byte[] value, out Uuid96 result)

Reads an 96-bit UUID from slice of memory

  • value — Array of bytes that is either empty, or holds at least 12 bytes
  • result — Corresponding Uuid96, if the read is successful

Returns: true if value has length 0 or at least 12; otherwise, false.

If value is larger than 12 bytes, the additional bytes will be ignored.

static bool TryRead(Slice value, out Uuid96 result)

Reads an 96-bit UUID from slice of memory

  • value — Slice of bytes that is either empty, or holds at least 12 bytes
  • result — Corresponding Uuid96, if the read is successful

Returns: true if value has length 0 or at least 12; otherwise, false.

If value is larger than 12 bytes, the additional bytes will be ignored.

static bool TryRead(ReadOnlySpan<byte> value, out Uuid96 result)

Reads an 96-bit UUID from slice of memory

  • value — Span of bytes that is either empty, or holds at least 12 bytes
  • result — Corresponding Uuid96, if the read is successful

Returns: true if value has length 0 or at least 12; otherwise, false.

If value is larger than 12 bytes, the additional bytes will be ignored.

TryWriteTo

bool TryWriteTo(Span<byte> destination)

Writes the bytes of this instance to the specified destination, if it is large enough.

  • destination — Buffer where the bytes will be written to, with a capacity of at least 12 bytes

Returns: true if the destination is large enough; otherwise, false

bool TryWriteTo(Span<byte> destination, out int bytesWritten)

Writes the bytes of this instance to the specified destination, if it is large enough.

  • destination — Buffer where the bytes will be written to, with a capacity of at least 12 bytes
  • bytesWritten — Receives the number of bytes written (either 12 or 0)

Returns: true if the destination is large enough; otherwise, false

WriteTo

void WriteTo(ref SliceWriter writer)

Writes this UUID to the specified writer

void WriteTo(Span<byte> destination)

Fields

AllBitsSet

static readonly Uuid96 AllBitsSet

Uuid96 with all bits set to 1 ("FFFFFFFF-FFFFFFFF-FFFFFFFF")

Empty

static readonly Uuid96 Empty

Uuid96 with all bits set to 0 ("00000000-00000000-00000000")

MaxValue

static readonly Uuid96 MaxValue

Uuid96 with all bits set to 1 ("FFFFFFFF-FFFFFFFF-FFFFFFFF")

MinValue

static readonly Uuid96 MinValue

Uuid96 with all bits set to 0 ("00000000-00000000-00000000")

One

static readonly Uuid96 One

Uuid96 with only bit 0 set to 1 ("00000000-00000000-00000001")

SizeOf

const int SizeOf

Size is 12 bytes