Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Getting Started

Taiizor edited this page Dec 28, 2024 · 5 revisions

🚀 Getting Started

Installation

UUID is distributed via NuGet. You can install it using one of the following methods:

Package Manager (PM)

Install-Package UUID

.NET CLI

dotnet add package UUID

Basic Usage

1. Create a New UUID

// Create a new UUID
UUID id = new UUID();

// Get string representation
string idString = id.ToString(); // "0123456789ABCDEF0123456789ABCDEF"

2. Parse UUID from String

// Parse from string
string uuidString = "0123456789ABCDEF0123456789ABCDEF";
UUID parsed = UUID.Parse(uuidString);

// Try parse (safer)
UUID result;
if (UUID.TryParse(uuidString, out result))
{
    // Successfully parsed
}

3. Convert to/from Guid

// From Guid
Guid guid = Guid.NewGuid();
UUID fromGuid = UUID.FromGuid(guid);

// To Guid
Guid toGuid = fromGuid.ToGuid();

4. Different String Formats

UUID id = new UUID();

// Different string representations
string hex = id.ToString();      // Hexadecimal
string base32 = id.ToBase32();   // Base32
string base64 = id.ToBase64();   // Base64

5. Thread-Safe Operations

// Thread-safe UUID generation
Parallel.For(0, 1000, _ => {
    UUID id = new UUID();
    // Use the ID safely across threads
});

Next Steps

Common Issues and Solutions

  1. Performance in High-Load Scenarios

    • Use the built-in thread-safe generation
    • Consider bulk generation for batch operations
  2. String Format Compatibility

    • Use appropriate string format methods based on your needs
    • Consider using Base32 for URL-safe strings
  3. Memory Usage

    • UUID struct is optimized for minimal memory footprint
    • Use array pooling for bulk operations

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.