Creating GUIDs with C#


The problem with GUIDs was not an easy one to solve with Visual C++, Visual Basic, etc.

To create and view a GUID(globally uniqueidentifier) you had to call the API UUIDCreate() and then callUUIDToString() to transform the GUID into String.

Now with C# you don't have such sophisticated code.

By the way, you must know that the created GUID is realy globally unique only in case your computer has a Network Adapter.In case it doesn't, the GUID is only locally unique!

Here is an example of creating a GUID in C#:

using System;

namespace PavelTsekov
{
class MainClass
{
static void Main(string[] args)
{
//let's create a GUID with C#
System.Guid guid=System.Guid.NewGuid();
Console.WriteLine(guid.ToString());
Console.ReadLine();
}
}
}

Most Commented Articles :

Twitter Digg Delicious Stumbleupon Technorati Facebook Email

No comments yet... Be the first to leave a reply!