NewGuid vs System.Guid.NewGuid().ToString(“D”);

前端 未结 4 1622
清酒与你
清酒与你 2021-01-30 17:35

Is there a difference when you generate a GUID using NewGuid(); vs System.Guid.NewGuid().ToString(\"D\"); or they are the same thing?

4条回答
  •  时光取名叫无心
    2021-01-30 18:05

    The generation algorithm has to be the same for both, because System.Guid.NewGuid().ToString("D") is calling System.Guid.NewGuid(), and then calling ToString on the result, i.e., both of your examples are calling the same method to generate the guid. As to comparing the "format" - this does not make sense because System.Guid.NewGuid() does not have a "format" in the same way as System.Guid.NewGuid().ToString("D") - it is only by calling the ToString method that you give the internal representation of the guid an external, string format. The format the string takes will depend on the argument you pass to the string method.

提交回复
热议问题