System.Guid Structure

Represents a globally unique identifier (GUID).

Namespace: System

Assembly: System.Runtime (in System.Runtime.dll)

Syntax

public struct Guid

Remarks

A GUID is a 128-bit integer that is unique across both space and time with a very high probability. It is used to identify objects, interfaces, and other items.

GUIDs are composed of 32 hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12. For example:

3F2504E0-43BE-4B21-B703-71F8A832F6C5

The .NET Framework provides the Guid structure to represent GUIDs. You can use this structure to generate new GUIDs, parse existing GUIDs, and perform comparisons.

Constructors

Name Description
Guid(byte[]) Initializes a new instance of the Guid structure with the specified array of bytes.
Guid(int, short, short, byte[]) Initializes a new instance of the Guid structure with the specified integers and byte array.
Guid(int, short, short, byte, byte, byte, byte, byte, byte, byte, byte) Initializes a new instance of the Guid structure with the specified integers and bytes.
Guid(string) Initializes a new instance of the Guid structure from the specified string representation.

Fields

Name Description
Empty Gets a new instance of the Guid structure that is guaranteed to be the same as the Guid(0,0,0,0,0,0,0,0,0,0,0) structure, i.e. all zeros.

Methods

Name Description
CompareTo(object) Compares the current instance with another object of the same type.
CompareTo(Guid) Compares the current instance with another Guid structure.
Equals(object) Determines whether the specified object is equal to the current instance.
Equals(Guid) Determines whether the specified Guid structure is equal to the current instance.
GetHashCode() Returns the hash code for the current instance.
NewGuid() Initializes a new instance of the Guid structure.
Parse(string) Converts the specified string representation of a GUID to its Guid equivalent.
ToString() Returns the string representation of this instance.
ToString(string format) Converts the value of this instance to its equivalent string representation using the specified format.
TryFormat(Span<char>, int&, ReadOnlySpan<char>, ...) Attempts to format the current Guid into the provided buffer as a string.

Operators

Name Description
== Compares two Guid structures for equality.
!= Compares two Guid structures for inequality.

See Also