Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct System.​Guid

Assembly: System.Runtime

Represents a globally unique identifier (GUID).

Fields and Constants

public static readonly Guid
Empty
A read-only instance of the <see cref="T:System.Guid" /> structure whose value is all zeros.

Properties

public int
Variant
Gets the value of the variant field for the <see cref="T:System.Guid" /> .
public int
Version
Gets the value of the version field for the <see cref="T:System.Guid" /> .

Methods

public int
CompareTo​(Guid value)
value An object to compare to this instance.
Returns A signed number indicating the relative values of this instance and <paramref name="value" /> . <list type="table"> <listheader> <term> Return value</term> <description> Description</description> </listheader> <item> <term> A negative integer</term> <description> This instance is less than <paramref name="value" />.</description> </item> <item> <term> Zero</term> <description> This instance is equal to <paramref name="value" />.</description> </item> <item> <term> A positive integer</term> <description> This instance is greater than <paramref name="value" />.</description> </item> </list>
Compares this instance to a specified <see cref="T:System.Guid" /> object and returns an indication of their relative values.
public int
CompareTo​(object value)
value An object to compare, or <see langword="null" /> .
Returns A signed number indicating the relative values of this instance and <paramref name="value" /> . <list type="table"> <listheader> <term> Return value</term> <description> Description</description> </listheader> <item> <term> A negative integer</term> <description> This instance is less than <paramref name="value" />.</description> </item> <item> <term> Zero</term> <description> This instance is equal to <paramref name="value" />.</description> </item> <item> <term> A positive integer</term> <description> This instance is greater than <paramref name="value" />, or <paramref name="value" /> is <see langword="null" />.</description> </item> </list>
Compares this instance to a specified object and returns an indication of their relative values.
public bool
Equals​(Guid g)
g An object to compare to this instance.
Returns <see langword="true" /> if <paramref name="g" /> is equal to this instance; otherwise, <see langword="false" /> .
Returns a value indicating whether this instance and a specified <see cref="T:System.Guid" /> object represent the same value.
public bool
Equals​(object o)
o The object to compare with this instance.
Returns <see langword="true" /> if <paramref name="o" /> is a <see cref="T:System.Guid" /> that has the same value as this instance; otherwise, <see langword="false" /> .
Returns a value that indicates whether this instance is equal to a specified object.
public int
GetHashCode​()
Returns The hash code for this instance.
Returns the hash code for this instance.
public byte[]
ToByteArray​()
Returns A 16-element byte array.
Returns a 16-element byte array that contains the value of this instance.
public byte[]
ToByteArray​(bool bigEndian)
public string
ToString​()
Returns The value of this <see cref="T:System.Guid" /> , formatted by using the "D" format specifier as follows: <c>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</c> where the value of the GUID is represented as a series of lowercase hexadecimal digits in groups of 8, 4, 4, 4, and 12 digits and separated by hyphens. An example of a return value is "382c74c3-721d-4f34-80e5-57657b6cbc27". To convert the hexadecimal digits from a through f to uppercase, call the <see cref="M:System.String.ToUpper" /> method on the returned string.
Returns a string representation of the value of this instance in registry format.
public string
ToString​(string format)
format A single format specifier that indicates how to format the value of this <see cref="T:System.Guid" /> . The <paramref name="format" /> parameter can be "N", "D", "B", "P", or "X". If <paramref name="format" /> is <see langword="null" /> or an empty string (""), "D" is used.
Returns The value of this <see cref="T:System.Guid" /> , represented as a series of lowercase hexadecimal digits in the specified format.
Returns a string representation of the value of this <see cref="T:System.Guid" /> instance, according to the provided format specifier.
public string
ToString​(string format, IFormatProvider provider)
format A single format specifier that indicates how to format the value of this <see cref="T:System.Guid" /> . The <paramref name="format" /> parameter can be "N", "D", "B", "P", or "X". If <paramref name="format" /> is <see langword="null" /> or an empty string (""), "D" is used.
provider (Reserved) An object that supplies culture-specific formatting information.
Returns The value of this <see cref="T:System.Guid" /> , represented as a series of lowercase hexadecimal digits in the specified format.
Returns a string representation of the value of this instance of the <see cref="T:System.Guid" /> class, according to the provided format specifier and culture-specific format information.
public bool
TryFormat​(Span`1 utf8Destination, Int32& bytesWritten, ReadOnlySpan`1 format = null)
public bool
TryFormat​(Span`1 destination, Int32& charsWritten, ReadOnlySpan`1 format = null)
public bool
TryWriteBytes​(Span`1 destination)
public bool
TryWriteBytes​(Span`1 destination, bool bigEndian, Int32& bytesWritten)
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .