public static void Main()
string[] formats = {"N", "D", "B", "P", "X"};
Guid guid = Guid.NewGuid();
var stringGuids = new string[formats.Length];
for (int ctr = 0; ctr < formats.Length; ctr++)
stringGuids[ctr] = guid.ToString(formats[ctr]);
const string exactFormatTest = "B";
foreach (var stringGuid in stringGuids)
Guid newGuid = Guid.ParseExact(stringGuid, exactFormatTest);
Console.WriteLine("Successfully parsed exact ({1}) {0}", stringGuid, exactFormatTest);
catch (ArgumentNullException)
Console.WriteLine("The string to be parsed is null.");
Console.WriteLine("Bad Format when parse exact({1}): {0}", stringGuid, exactFormatTest);
Guid newGuid = Guid.Parse(stringGuid);
Console.WriteLine("Successfully parsed {0}", stringGuid);
catch (ArgumentNullException)
Console.WriteLine("The string to be parsed is null.");
Console.WriteLine("Bad Format when parse: {0}", stringGuid);