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

前端 未结 10 912
挽巷
挽巷 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:05

    You're missing the () after ToString that marks it as a function call vs. a function reference (the kind you pass to delegates), which incidentally is why c# has no AddressOf operator, it's implied by how you type it.

    Try this:

    string guid = System.Guid.NewGuid().ToString();
    

提交回复
热议问题