Initializes a new instance of the Guid class.
Namespace:
System
Assembly:
mscorlib (in mscorlib.dll)
'Usage
Dim returnValue As Guid
returnValue = Guid.NewGuid()
'Declaration
Public Shared Function NewGuid As Guid
This is a convenient static method that you can call to get a new Guid.
There is a very low probability that the value of the new Guid is all zeroes or equal to any other Guid.
The following code example creates and displays the value of two Guid objects.
' This code example demonstrates the Guid.NewGuid() method.
Imports System
Class Sample
Public Shared Sub Main()
Dim g As Guid
' Create and display the value of two GUIDs.
g = Guid.NewGuid()
Console.WriteLine(g)
Console.WriteLine(Guid.NewGuid())
End Sub 'Main
End Class 'Sample
'
'This code example produces the following results:
'
'0f8fad5b-d9cb-469f-a165-70867728950e
'7c9e6679-7425-40de-944b-e07fc1f90ae7
'
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
.NET Compact Framework
Supported in: 3.5, 2.0
XNA Framework
Supported in: 3.0, 2.0, 1.0
Reference