Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Create a unique GUID

Total Hit ( 4261)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


The System.Guid type exposes several shared and instance methods that can help you work with GUIDs, that is, those 128-bit numbers that serve to uniquely identify elements and that are ubiquitous in Windows programming. The most important member is the NewGuid shared method is useful for generating a new unique identifier:

Click here to copy the following block
' Create a new GUID.
Dim guid1 As Guid = Guid.NewGuid
' By definition, you'll surely get a different output here.
Console.WriteLine(guid1.ToString)
  '=> 3f5f1d42-2d92-474d-a2a4-1e707c7e2a37

There are two things you can do with a Guid object: you can convert it to a Byte array with the ToByteArray method, and you can compare two Guid values for equality using the Equals method (inherited from System.Object):

Click here to copy the following block
' Convert to an array of bytes.
Dim bytes() As Byte = guid1.ToByteArray
Dim b As Byte
For Each b In bytes
  Console.Write(b.ToString & " ")
    ' => 239 1 161 57 143 200 172 70 185 64 222 29 59 15 190 205
Next

' Compare two GUIDs.
If Not guid1.Equals(guid2) Then
  Console.WriteLine("GUIDs are different.")
End If


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.