Why isn't Guid.ToString(“n”) the same as a hex string generated from a byte array of the same guid?

后端 未结 3 1198
面向向阳花
面向向阳花 2021-02-13 12:40

Consider the following unit test:

    [TestMethod]
    public void TestByteToString()
    {
        var guid = new Guid(\"61772f3ae5de5f4a8577eb1003c5c054\");
           


        
3条回答
  •  隐瞒了意图╮
    2021-02-13 13:08

    A GUID is structured as follows:

    int a
    short b
    short c
    byte[8] d
    

    So for the part represented by a your code gets the bytes reversed. All other parts are transformed correctly.

提交回复
热议问题