I want to define User Define Guid in C#. I want to insert this in my Guid object:
dddddddddddddddddddddddddddddddd.
When I do this:
Guid user = "dddddddddddddddddddddddddddddddd";
I get the err: System cannot convert from String to System.Guid. What should I do here?
It sounds like you want:
Note that when you print the guid out again, it will be formatted differently:
You could call the
Guid(string)constructor instead, but personally I prefer calling theParsemethod – it’s more descriptive of what’s going on, and it follows the same convention asint.Parseetc. On the other hand,Guid.Parsewas only introduced in .NET 4 – if you’re on an older version of .NET, you’ll need to use the constructor. I believe there are some differences in terms of which values will be accepted by the different calls, but I don’t know the details.