Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

C# & Databases - Creating a unique identifer

Creating a new GUID in C# is not as straightforward as one would think. Calling the constructor of System.Guid() will produce a GUID of all zeroes. Using System.Guid.NewGuid() will produce the desired effect of a new, unique identifier.

   1  
   2  // produces a "blank" GUID: '00000000-0000-0000-0000-000000000000'
   3  System.Guid blankGuid = new System.Guid(); 
   4  
   5  // produces a new, unique GUID: '96d36892-6eed-400c-91f8-a194f3522fae'
   6  System.Guid desiredGuid = System.Guid.NewGuid(); 
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS