5

Possible Duplicate:
Why is the GUID structure declared the way it is?

i've been looking a GUID generation and handling and is wondering why Microsoft has decided these "strange" formats.

A single format specifier that indicates how to format the value of this Guid. The format parameter can be "N", "D", "B", "P", or "X". If format is null or an empty string (""), "D" is used.

Say what?

Format flags goes as following:

N: 32 digits = 00000000000000000000000000000000

D: 32 digits separated by hyphens = 00000000-0000-0000-0000-000000000000

B: 32 digits separated by hyphens, enclosed in braces = {00000000-0000-0000-0000-000000000000}

P: 32 digits separated by hyphens, enclosed in parentheses = (00000000-0000-0000-0000-000000000000)

X: Four hexadecimal values enclosed in braces, where the fourth value is a subset of eight hexadecimal values that is also enclosed in braces = {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}

Why???

Why not a 00000000-00000000-00000000-00000000

or 0000-0000-0000-0000-0000-0000-0000-0000 ??

Does any one have a good answer, except its Microsoft? :o)

6
  • "It's Microsoft" isn't even a good answer because GUID is just Microsoft's implementation of the UUID standard (Universally unique identifier), which defines the same format. en.wikipedia.org/wiki/Universally_Unique_Identifier
    – Matt
    Jul 6, 2011 at 14:46
  • Apologies, twitchy "close" finger, not a duplicate of that question. Jul 6, 2011 at 14:48
  • As a random aside, I had not previously known that guid actually had associated format strings. Does this mean that Guid.Parse or other similar tool can take in the format string in reverse with the guid instead of manually inserting hyphens etc into a string before converting it? | Also wish I could vote to not close so best i can do is +1 it. Jul 6, 2011 at 14:56
  • Have a look here: stackoverflow.com/questions/276524/…
    – Emond
    Jul 6, 2011 at 15:05
  • Thanks all, it didnt really answer my initial question: whats up with the different formats, but @loan provided me with the link that explained it to me. Thanks for the effort though. Jul 17, 2011 at 19:44

1 Answer 1

5

UUID/GUID have standard representations according to RFC-4122. Simpler explanation here.

2
  • +1: In particular, see page 3. Jul 6, 2011 at 14:52
  • thanks for the answer, that was a bit more explaining than the agressive "closed as exact duplicate" which I didnt think it was. At least I got my answer now. Jul 17, 2011 at 19:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.