Sunday, September 16, 2007

GUIDs and C#

I've started using GUIDs (pronounced "goo-id") which are globally unique 128-bit integers (displayed as HEX). I created a small program to generate and display a GUID using the System.Guid.NewGuid() method in C#.



Here's the opening screen:



After clicking the 'Create GUID' button, the new GUID is displayed:

The code used to generate the GUID is as follows:


Guid myGUID = System.Guid.NewGuid();
labelGUID.Text = myGUID.ToString();



I'm starting to prefer this method of creating ID values for data tables more than the indexing values I currently use. This should make maintaining disconnected databases on handheld devices much simpler and more effective.

No comments: