API Reference

UUID Struct

The core struct representing a UUID value.

public readonly partial struct UUID : IEquatable<UUID>, IComparable<UUID>, IComparable

Properties

Property Type Description
Empty UUID Gets the empty UUID value (all zeros)
Version byte Gets the UUID version number
Variant byte Gets the UUID variant number

Constructors

// Create a new random UUID
public UUID()

// Create from bytes
public UUID(ReadOnlySpan<byte> bytes)

// Create from string
public static UUID Parse(string input)
public static UUID Parse(ReadOnlySpan<char> input)

// Try parse from string
public static bool TryParse(string input, out UUID result)
public static bool TryParse(ReadOnlySpan<char> input, out UUID result)

Methods

String Formatting

// Convert to standard string format
public override string ToString()

// Convert to Base32 format
public string ToBase32()

// Convert to Base64 format
public string ToBase64()

// Convert from Base64 format
public static UUID FromBase64(string base64)
public static bool TryFromBase64(string base64, out UUID result)

Byte Array Operations

// Convert to byte array
public byte[] ToByteArray()
public bool TryWriteBytes(byte[] destination)
public bool TryWriteBytes(Span<byte> destination)

// Convert from byte array
public static UUID FromByteArray(byte[] bytes)
public static bool TryFromByteArray(byte[] bytes, out UUID result)

Guid Operations

// Convert to/from Guid (implicit operators)
public static implicit operator Guid(UUID uuid)
public static implicit operator UUID(Guid guid)

// Explicit conversion methods
public Guid ToGuid()
public static UUID FromGuid(Guid guid)

Comparison Methods

public bool Equals(UUID other)
public override bool Equals(object obj)
public override int GetHashCode()
public int CompareTo(UUID other)
public int CompareTo(object? obj)

public static bool operator ==(UUID left, UUID right)
public static bool operator !=(UUID left, UUID right)
public static bool operator <(UUID left, UUID right)
public static bool operator >(UUID left, UUID right)
public static bool operator <=(UUID left, UUID right)
public static bool operator >=(UUID left, UUID right)

Extension Methods

// Array extensions
public static class ArrayExtension
{
    // Generate array of UUIDs
    public static UUID[] Generate(int count)
    
    // Try generate array of UUIDs
    public static bool TryGenerate(int count, out UUID[]? result)
    
    // Fill array with UUIDs
    public static void Fill(this UUID[] array)
    
    // Try fill array with UUIDs
    public static bool TryFill(this UUID[] array)
}

Exceptions

FormatException

Thrown when:

  • Invalid string format in Parse methods
  • Invalid byte array length in constructor

ArgumentNullException

Thrown when:

  • Null input string in Parse methods
  • Null byte array in constructor