How many characters are there in a GUID?
Solution 1
From MSDN:
A GUID is a 128-bit value consisting of one group of 8 hexadecimal digits, followed by three groups of 4 hexadecimal digits each, followed by one group of 12 hexadecimal digits. The following example GUID shows the groupings of hexadecimal digits in a GUID: 6B29FC40-CA47-1067-B31D-00DD010662DA
From Wikipedia:
Often braces are added to enclose the above format, as such:
{3F2504E0-4F89-11D3-9A0C-0305E82C3301}
So a total of 38 characters in the typical hexadecimal encoding with curly braces.
-Adam
Solution 2
TL;DR: None.
As Adam Davis stated, the Microsoft style is HEX encoding (with braces and dashes to make it more readable) that can be displayed using a subset of ASCII characters (0-9 and A-F), but this is not specifically ASCII encoding.
I guess it's important to remember that the microsoft style of displaying GUID's is only a representation of a GUID, which is actually a 16 byte integral value (as Micheal Trausch stated).
You can also present it in different, more compact ways by converting the bytes into a different character set (like ASCII).
Theoretically you can display each byte as an extended ASCII character (255 characters), which would allow you to save a GUID as a 16 character length string.
It wouldn't be very readable though because it would include whitespace characters (CR, space, tab, etc) and other special characters, so this would only make sense if you want to efficiently save a GUID in a non-human readable character format, for example in in a database that doesn't natively support GUID's or fast matching of small binary values: http://en.wikipedia.org/wiki/Extended_ASCII
IMHO the most readable way to display a GUID more compact would be to use Base64 encoding, which allows you to save it in a string with a length of 22 characters, and would make it look like this:
7v26IM9P2kmVepd7ZxuXyQ==
But as Jeff Atwood states on his site, you can also push a GUID into an ASCII85 encoded string with 20 characters:
[Rb*hlkkXVW+q4s(YSF0
For more inspiration, see: http://www.codinghorror.com/blog/2005/10/equipping-our-ascii-armor.html
Solution 3
As Adam mentioned from the MSDN quote, UUIDs are 128-bit values. This means that they take 16 bytes of RAM to hold a value. A text representation will take 32 bytes (two bytes for each single byte), plus the 4 hyphens, plus the two brackets if you want to include those; this amounts to 38 bytes.
Just keep in mind that if you are exposing UUIDs to users of your software, they may provide the UUID with or without the brackets. If you're storing the value anywhere, it's best to store it as the 16-byte binary representation. If you are interoperating with other UUID implementations, you may want to use the basic text format for interoperability, since different implementations do different things to the order of bytes when storing a binary UUID value.
Solution 4
The length depends on the encoding. You can get the standard encoding and length with this snippet:
public void Main()
{
var guid = Guid.Empty;
Write(guid, "N"); // 32 characters
Write(guid, "D"); // 36 characters (default)
Write(guid, "B"); // 38 characters
Write(guid, "P"); // 38 characters
Write(guid, "X"); // 68 characters
}
private void Write(Guid guid, string format)
{
var guidString = guid.ToString(format);
Console.WriteLine("{0}: {1} ({2} characters)", format, guidString, guidString.Length);
}
See the Guid.ToString method for details:
Related videos on Youtube

Comments
-
Jim Counts almost 4 years
Using ASCII encoding, how many characters are there in a GUID?
I'm interested in the Microsoft style, which includes the curly brackets and dashes.
-
Greg Hewgill over 14 yearsThey're all exactly the same length. If you count the characters in one, you'll know the length of all of them.
-
Adam Davis over 14 years@Greg - That's a very poor assumption to make, unless you understand that the length will not vary.
-
Greg Hewgill over 14 yearsIf the length varied, then this question would be like asking, "how long is a piece of string?" Instead, this is asking "how many eggs in a dozen?"
-
Jim Counts over 14 yearsWhen I googled this question, every answer just pointed to a definition of a guid. Downvote me if you want, but I'm just trying to make the answer to this sepceific question easier to find, with no counting needed for future askers.
-
Adam Davis over 14 yearsI understand what you're saying, but if someone has just been introduced to NewDataX, the question as to length is valid, and you can't assume that what you've seen exemplifies every other NewDataX until you understand what a NewDataX is.
-
-
Randolpho over 14 years@magnifico -- see the last paragraph of this answer: "So a total of 38 characters in the typical hexadecimal encoding with curly braces."
-
Adam Davis over 14 yearsNo need to fight with magnifico - he asked the question, he gets to decide who gave the most relevant answer. He has his reasons for preferring the other answer to this one, I'm sure.
-
sheikhjabootie almost 13 yearsI posted an Ascii-85 encoder/decoder in C# here: stackoverflow.com/questions/2827627/…
-
bugloaf about 10 years@Beska because that's what Stack Overflow is for. Instead of handing one person a fish, hand the same fish to a million people.
-
Beska about 10 years@bugloaf Hmm. I suspect both of my comments were in reference to something that has has been deleted, since they made no sense in the current context...and the first one was very specifically a response to something gone. I've gotten rid of them. (In the current context it looked like I was railing against the answer, which is a good answer, and which would make no sense for me to do, and which you were correctly calling out.)
-
KyleM almost 10 years@AdamDavis I count 32 not 38. edit: you must be counting the braces and dashes, nevermind.
-
jpmc26 about 6 yearsIf only this answer had a big, bold "None" at the top to bait readers and act as a TL;DR. ;)