Boost Your .NET Projects with Spargine: High-Performance ULIDs with the Ulid Struct

Spargine is a collection of open-source assemblies and NuGet packages designed for .NET 10, which I have been developing and maintaining since the release of .NET Framework 2. These assemblies are not only a core part of my projects but are also actively deployed in production environments across several companies I collaborate with.

Get Spargine

You can access the source code and NuGet packages here:

In Spargine 8, I introduced the UlidGenerator type to make working with ULIDs easier in .NET applications. For the .NET 10 release, I took this idea further — converting ULIDs into a first-class value type (struct) in the DotNetTips.Spargine.Core assembly, similar in spirit to the built-in Guid type.

Why? Because modern distributed applications increasingly need identifiers that are:

  • Globally unique
  • Fast to generate
  • And most importantly — naturally sortable by time

That’s where ULIDs (Universally Unique Lexicographically Sortable Identifiers) shine.

Unlike UUIDs/GUIDs — which are unique but not time-ordered — ULIDs embed a timestamp into the identifier. This means the IDs you generate today automatically sort ahead of the ones you generate tomorrow, without extra database fields or indexes.

The Ulid struct in Spargine makes ULIDs simple, lightweight, and highly performant to use across your .NET projects.

What is a ULID?

A ULID is a globally unique identifier designed as a more readable and sortable alternative to UUIDs. It combines time-based ordering with 80 bits of randomness, making it ideal for high-scale and distributed systems.

Structure of a ULID

  • 48-bit Timestamp
    Milliseconds since Unix epoch (1970-01-01T00:00:00Z), enabling natural time sorting.
  • 80-bit Randomness
    Ensures extremely high uniqueness, even at scale.

ULIDs are encoded as 26-character Base32 strings.

Example ULID

01ARZ3NDEKTSV4RRFFQ69G5FAV

Key Benefits of ULIDs

  1. Time-Based Sorting
    IDs naturally sort in chronological order — no extra timestamp fields required.
  2. Compact & Readable
    Shorter and friendlier than UUID/GUID values.
  3. High Uniqueness
    80-bit randomness provides huge entropy, minimizing collisions.
  4. Designed for Distributed Systems
    Works beautifully in microservices, queues, logging, and event sourcing.
  5. Embedded Temporal Metadata
    You can extract the timestamp directly from the ID.
  6. Cross-Language Support
    ULIDs are implemented widely across platforms — perfect for polyglot systems.

Put simply, ULIDs give you structured uniqueness with chronological meaning.

The Spargine Ulid Struct

The Ulid struct in DotNetTips.Spargine.Core is designed to feel natural in .NET — much like Guid, but smarter for time-ordered operations.

Constructor

  • Ulid(string value)
    Initializes a new instance of the Ulid struct.

Methods

  • GetTimeStamp()
    Extracts the timestamp from the Ulid.
  • Parse(string value)
    Parses a string into a Ulid instance.
  • TryParse(string value, out Ulid ulid)
    Tries to parse a string into a Ulid instance.
  • Ulid NewUlid()
    Generates a new Ulid.

These APIs make ULIDs simple, predictable, and safe to consume in your applications.

Summary

The new Ulid struct in Spargine brings ordered, human-readable, high-entropy identifiers natively into your .NET 10 applications — without the complexity of rolling your own implementation.

If you’re working with:

  • Distributed systems
  • Event-driven architectures
  • Logging and tracing
  • Databases that benefit from ordered inserts
  • Systems where timestamp context matters

…then ULIDs are often a smarter alternative to GUIDs — and Spargine makes them effortless to use.

This enhancement is another step in Spargine’s mission to deliver high-performance, developer-friendly utilities that help you write cleaner, faster, more maintainable .NET code.

Get Involved!

The success of open-source projects like Spargine relies on community contributions. If you find these updates useful or have ideas for further improvements, I encourage you to contribute by:

  • Submitting pull requests
  • Reporting issues
  • Suggesting new features

Your input is invaluable in making Spargine an even more powerful tool for the .NET community.

If you are interested in contributing or have any questions, feel free to contact me via email at dotnetdave@live.com. Your support and collaboration are greatly appreciated!

Thank you, and happy coding!

Pick up any books by David McCarter by going to Amazon.com: http://bit.ly/RockYourCodeBooks

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

$5.00
$15.00
$100.00
$5.00
$15.00
$100.00
$5.00
$15.00
$100.00

Or enter a custom amount

$

Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly

If you liked this article, please buy David a cup of Coffee by going here: https://www.buymeacoffee.com/dotnetdave

© The information in this article is copywritten and cannot be preproduced in any way without express permission from David McCarter.


Discover more from dotNetTips.com

Subscribe to get the latest posts sent to your email.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.