Monday, February 18, 2013

Guid.NewGuid() versus new Guid() in C#

  1. Here... Guid foo = Guid.NewGuid(); ...the foo variable will end up with a "real" Guid in it like 20cc2758-cdcf-48ab-ae06-7ab34c4df8d5 with random characters. The Guid will be different each time.
  2. But here... Guid bar = new Guid(); ...the bar variable will end up with the same string of zeros every time. 00000000-0000-0000-0000-000000000000 will be the value. There is no randomization.

No comments:

Post a Comment