C# Guid Empty
Description
Guid Empty
a read-only instance of the Guid structure
whose value is all zeros.
Syntax
Guid.Empty
has the following syntax.
public static readonly Guid Empty
Example
The following example uses the Equality operator to compare two GUID values with Guid.Empty to determine whether they consist exclusively of zeros.
using System;// w w w . j a va 2 s. c om
public class Example
{
public static void Main()
{
// Create a GUID and determine whether it consists of all zeros.
Guid guid1 = Guid.NewGuid();
Console.WriteLine(guid1);
Console.WriteLine("Empty: {0}\n", guid1 == Guid.Empty);
// Create a GUID with all zeros and compare it to Empty.
Byte[] bytes = new Byte[16];
Guid guid2 = new Guid(bytes);
Console.WriteLine(guid2);
Console.WriteLine("Empty: {0}", guid2 == Guid.Empty);
}
}
The code above generates the following result.