Giter VIP home page Giter VIP logo

csharp.ulid's Introduction

Universally Unique Lexicographically Sortable Identifier

C# .NET Standard 2.0 port of alizain/ulid

CI Downloads

Usage

using System;
using CSharp.Ulid;

internal class Program
{
    private static void Main(string[] args)
    {
        Ulid ulidRandom = Ulid.NewUlid();

        Ulid ulidSpecific = new Ulid
        {
            TimeStamp_0 = 3,
            TimeStamp_1 = 4,
            TimeStamp_2 = 5,
            TimeStamp_3 = 6,
            TimeStamp_4 = 7,
            TimeStamp_5 = 8,
            Randomness_0 = 13,
            Randomness_1 = 14,
            Randomness_2 = 15,
            Randomness_3 = 16,
            Randomness_4 = 17,
            Randomness_5 = 18,
            Randomness_6 = 19,
            Randomness_7 = 20,
            Randomness_8 = 21,
            Randomness_9 = 22,
        };

        Ulid ulidFromLongBytes = new Ulid(123456L, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });

        Ulid ulidFromBytesBytes = new Ulid(new byte[] { 0, 1, 2, 3, 4, 5 }, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });

        Ulid ulidFromBytes = new Ulid(new byte[] { 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });

        Ulid ulidFromReadOnlySpan = new Ulid(new ReadOnlySpan<byte>(new byte[] { 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }));

        Ulid.TryParse("00000000000000000000000000", out Ulid ulitParsed);

        Ulid ulidDefault = default(Ulid);

        byte[] byteExplicit = (byte[])new Ulid();

        byte[] byteFromMethod = new Ulid().ToByteArray();

        Span<byte> storage = stackalloc byte[100];
        Span<byte> slicedSpan = storage.Slice(start: 55, length: 30);
        Ulid.NewUlid().TryWriteBytes(slicedSpan); // if true, we should get 16-bytes of Ulid bytes written in `storage` starting at index 55.

        string stringRepresentation = new Ulid().ToString();

    }
}

Prior Art

csharp.ulid's People

Contributors

richardd2 avatar am11 avatar mcb2001 avatar waiyanmyintmo avatar teo-tsirpanis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.