Erik Porter Saves Time
Sounds like a nice headline for a newspaper, huh. I thought so too. Anyway, to the point of this post, I was struggling with formatting a Guid to the "registry" way of viewing it, you know - 32 digits separated by hyphens with curly brackets around it.
1st attempt - Code: String.Format("{{0}}", myguid)
1st attempt - Result: "{0}" <-- Which is very weird indeed, maybe a bug?
And then whammo! It dawned on me. I had just recently seen this post by Erik Porter...but I really didn't remember the meat of what Guid.ToString("N") meant (I hadn't pulled the post up yet).
2nd attempt - Code: myguid.ToString("N")
2nd attempt - Result: 23452345234235235242 (I know this isn't 32 digits)
Err - so that wasn't quite what I expected, but then again, I really wasn't sure what that "N" did. Ohh, so why not just open up the SDK docs, Microsoft had to have put something in there for the format I wanted. Ahh, sure enough, theres a "B" that gets what I want.
3rd attempt - Code myguid.ToString("B")
3rd attempt - Result: {2315123-2314-....}
Wahoo, Success! Man am I glad Erik saw & blogged about this the other week. Time saved, about 15 - 20 minutes wondering why the heck I'm getting {0} for the format of {{0}}. Thanks Erik!
PS - Whoever said blogs weren't a good source of information.