Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

C# & Databases - Creating A Unique Identifer

DZone's Guide to

C# & Databases - Creating A Unique Identifer

·
Free Resource
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.  


// produces a "blank" GUID: '00000000-0000-0000-0000-000000000000'
System.Guid blankGuid = new System.Guid(); 

// produces a new, unique GUID: '96d36892-6eed-400c-91f8-a194f3522fae'
System.Guid desiredGuid = System.Guid.NewGuid(); 
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}