Sequential GUIDs

后端 未结 5 2000
礼貌的吻别
礼貌的吻别 2020-12-08 23:02

I hope someone can answer this question.

How does the UuidCreateSequential method in the rpcrt4.dll class use to seed it\'s guids?

I know this much: Microsof

5条回答
  •  清歌不尽
    2020-12-08 23:36

    Rather than rely on the Win32 API, I typically use my own variant of a sequential guid which replaces eight bytes of the a standard guid with ticks from a datetime.

    var guidBinary = new byte[16];
    Array.Copy( Guid.NewGuid().ToByteArray(), 0, guidBinary, 0, 8 );
    Array.Copy( BitConverter.GetBytes( DateTime.Now.Ticks ), 0, guidBinary, 8, 8 );
    return new Guid( guidBinary );
    

提交回复
热议问题