Getting Started - Taiizor/UUID GitHub Wiki
🚀 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
- Check out Detailed Usage for advanced features
- Review Performance for optimization tips
- See Examples for more code samples
- Refer to API Reference for complete documentation
Common Issues and Solutions
-
Performance in High-Load Scenarios
- Use the built-in thread-safe generation
- Consider bulk generation for batch operations
-
String Format Compatibility
- Use appropriate string format methods based on your needs
- Consider using Base32 for URL-safe strings
-
Memory Usage
- UUID struct is optimized for minimal memory footprint
- Use array pooling for bulk operations