Guid.NewGuid Method
Initializes a new instance of the Guid structure.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
This is a convenient static method that you can call to get a new Guid.
The chance that the value of the new Guid will be all zeros or equal to any other Guid is very low. You can determine whether a GUID consists of all zeros by comparing it to Guid.Empty.
The following code example creates and displays the values of two Guid objects.
// This code example demonstrates the Guid.NewGuid() method. using System; class Sample { public static void Main() { Guid g; // Create and display the value of two GUIDs. g = Guid.NewGuid(); Console.WriteLine(g); Console.WriteLine(Guid.NewGuid()); } } /* This code example produces the following results: 0f8fad5b-d9cb-469f-a165-70867728950e 7c9e6679-7425-40de-944b-e07fc1f90ae7 */
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.