How to convert a GUID to a string in C#?

前端 未结 10 933
挽巷
挽巷 2020-12-15 02:20

I\'m new to C#.

I know in vb.net, i can do this:

Dim guid as string = System.Guid.NewGuid.ToString

In C#, I\'m trying to do

10条回答
  •  星月不相逢
    2020-12-15 03:04

    Here are examples of output from each of the format specifiers:

    N: cd26ccf675d64521884f1693c62ed303
    D: cd26ccf6-75d6-4521-884f-1693c62ed303
    B: {cd26ccf6-75d6-4521-884f-1693c62ed303}
    P: (cd26ccf6-75d6-4521-884f-1693c62ed303)
    X: {0xcd26ccf6,0x75d6,0x4521,{0x88,0x4f,0x16,0x93,0xc6,0x2e,0xd3,0x03}}
    

    The default is D.

    Run this yourself.

提交回复
热议问题