mscorlib(4.0.0.0) API with additions
System.Guid Struct Reference

Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type, see the Reference Source. More...

Inheritance diagram for System.Guid:
[legend]
Collaboration diagram for System.Guid:
[legend]

Public Member Functions

 Guid (byte[] b)
 Initializes a new instance of the T:System.Guid structure by using the specified array of bytes. More...
 
 Guid (uint a, ushort b, ushort c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k)
 Initializes a new instance of the T:System.Guid structure by using the specified unsigned integers and bytes. More...
 
 Guid (int a, short b, short c, byte[] d)
 Initializes a new instance of the T:System.Guid structure by using the specified integers and byte array. More...
 
 Guid (int a, short b, short c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k)
 Initializes a new instance of the T:System.Guid structure by using the specified integers and bytes. More...
 
 Guid (string g)
 Initializes a new instance of the T:System.Guid structure by using the value represented by the specified string. More...
 
byte [] ToByteArray ()
 Returns a 16-element byte array that contains the value of this instance. More...
 
override string ToString ()
 Returns a string representation of the value of this instance in registry format. More...
 
override int GetHashCode ()
 Returns the hash code for this instance. More...
 
override bool Equals (object o)
 Returns a value that indicates whether this instance is equal to a specified object. More...
 
bool Equals (Guid g)
 Returns a value indicating whether this instance and a specified T:System.Guid object represent the same value. More...
 
int CompareTo (object value)
 Compares this instance to a specified object and returns an indication of their relative values. More...
 
int CompareTo (Guid value)
 Compares this instance to a specified T:System.Guid object and returns an indication of their relative values. More...
 
string ToString (string format)
 Returns a string representation of the value of this T:System.Guid instance, according to the provided format specifier. More...
 
unsafe string ToString (string format, IFormatProvider provider)
 Returns a string representation of the value of this instance of the T:System.Guid class, according to the provided format specifier and culture-specific format information. More...
 
- Public Member Functions inherited from System.IEquatable< Guid >
bool Equals (T other)
 Indicates whether the current object is equal to another object of the same type. More...
 

Static Public Member Functions

static Guid Parse (string input)
 Converts the string representation of a GUID to the equivalent T:System.Guid structure. More...
 
static bool TryParse (string input, out Guid result)
 Converts the string representation of a GUID to the equivalent T:System.Guid structure. More...
 
static Guid ParseExact (string input, string format)
 Converts the string representation of a GUID to the equivalent T:System.Guid structure, provided that the string is in the specified format. More...
 
static bool TryParseExact (string input, string format, out Guid result)
 Converts the string representation of a GUID to the equivalent T:System.Guid structure, provided that the string is in the specified format. More...
 
static bool operator== (Guid a, Guid b)
 Indicates whether the values of two specified T:System.Guid objects are equal. More...
 
static bool operator != (Guid a, Guid b)
 Indicates whether the values of two specified T:System.Guid objects are not equal. More...
 
static Guid NewGuid ()
 Initializes a new instance of the T:System.Guid structure. More...
 

Static Public Attributes

static readonly Guid Empty
 A read-only instance of the T:System.Guid structure whose value is all zeros. More...
 

Detailed Description

Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type, see the Reference Source.

Definition at line 14 of file Guid.cs.

Constructor & Destructor Documentation

◆ Guid() [1/5]

System.Guid.Guid ( byte []  b)

Initializes a new instance of the T:System.Guid structure by using the specified array of bytes.

Parameters
bA 16-element byte array containing values with which to initialize the GUID.
Exceptions
T:System.ArgumentNullExceptionb is null.
T:System.ArgumentExceptionb is not 16 bytes long.

Definition at line 157 of file Guid.cs.

◆ Guid() [2/5]

System.Guid.Guid ( uint  a,
ushort  b,
ushort  c,
byte  d,
byte  e,
byte  f,
byte  g,
byte  h,
byte  i,
byte  j,
byte  k 
)

Initializes a new instance of the T:System.Guid structure by using the specified unsigned integers and bytes.

Parameters
aThe first 4 bytes of the GUID.
bThe next 2 bytes of the GUID.
cThe next 2 bytes of the GUID.
dThe next byte of the GUID.
eThe next byte of the GUID.
fThe next byte of the GUID.
gThe next byte of the GUID.
hThe next byte of the GUID.
iThe next byte of the GUID.
jThe next byte of the GUID.
kThe next byte of the GUID.

Definition at line 194 of file Guid.cs.

◆ Guid() [3/5]

System.Guid.Guid ( int  a,
short  b,
short  c,
byte []  d 
)

Initializes a new instance of the T:System.Guid structure by using the specified integers and byte array.

Parameters
aThe first 4 bytes of the GUID.
bThe next 2 bytes of the GUID.
cThe next 2 bytes of the GUID.
dThe remaining 8 bytes of the GUID.
Exceptions
T:System.ArgumentNullExceptiond is null.
T:System.ArgumentExceptiond is not 8 bytes long.

Definition at line 219 of file Guid.cs.

◆ Guid() [4/5]

System.Guid.Guid ( int  a,
short  b,
short  c,
byte  d,
byte  e,
byte  f,
byte  g,
byte  h,
byte  i,
byte  j,
byte  k 
)

Initializes a new instance of the T:System.Guid structure by using the specified integers and bytes.

Parameters
aThe first 4 bytes of the GUID.
bThe next 2 bytes of the GUID.
cThe next 2 bytes of the GUID.
dThe next byte of the GUID.
eThe next byte of the GUID.
fThe next byte of the GUID.
gThe next byte of the GUID.
hThe next byte of the GUID.
iThe next byte of the GUID.
jThe next byte of the GUID.
kThe next byte of the GUID.

Definition at line 255 of file Guid.cs.

◆ Guid() [5/5]

System.Guid.Guid ( string  g)

Initializes a new instance of the T:System.Guid structure by using the value represented by the specified string.

Parameters
gA string that contains a GUID in one of the following formats ("d" represents a hexadecimal digit whose case is ignored): 32 contiguous digits: dddddddddddddddddddddddddddddddd -or- Groups of 8, 4, 4, 4, and 12 digits with hyphens between the groups. The entire GUID can optionally be enclosed in matching braces or parentheses: dddddddd-dddd-dddd-dddd-dddddddddddd -or- {dddddddd-dddd-dddd-dddd-dddddddddddd} -or- (dddddddd-dddd-dddd-dddd-dddddddddddd) -or- Groups of 8, 4, and 4 digits, and a subset of eight groups of 2 digits, with each group prefixed by "0x" or "0X", and separated by commas. The entire GUID, as well as the subset, is enclosed in matching braces: {0xdddddddd, 0xdddd, 0xdddd,{0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd}} All braces, commas, and "0x" prefixes are required. All embedded spaces are ignored. All leading zeros in a group are ignored.The digits shown in a group are the maximum number of meaningful digits that can appear in that group. You can specify from 1 to the number of digits shown for a group. The specified digits are assumed to be the low-order digits of the group.
Exceptions
T:System.ArgumentNullExceptiong is null.
T:System.FormatExceptionThe format of g is invalid.
T:System.OverflowExceptionThe format of g is invalid.

Definition at line 277 of file Guid.cs.

Member Function Documentation

◆ CompareTo() [1/2]

int System.Guid.CompareTo ( object  value)

Compares this instance to a specified object and returns an indication of their relative values.

Parameters
valueAn object to compare, or null.
Returns
A signed number indicating the relative values of this instance and value .Return value Description A negative integer This instance is less than value . Zero This instance is equal to value . A positive integer This instance is greater than value , or value is null.
Exceptions
T:System.ArgumentExceptionvalue is not a T:System.Guid.

Definition at line 1108 of file Guid.cs.

◆ CompareTo() [2/2]

int System.Guid.CompareTo ( Guid  value)

Compares this instance to a specified T:System.Guid object and returns an indication of their relative values.

Parameters
valueAn object to compare to this instance.
Returns
A signed number indicating the relative values of this instance and value .Return value Description A negative integer This instance is less than value . Zero This instance is equal to value . A positive integer This instance is greater than value .

Definition at line 1170 of file Guid.cs.

◆ Equals() [1/2]

override bool System.Guid.Equals ( object  o)

Returns a value that indicates whether this instance is equal to a specified object.

Parameters
oThe object to compare with this instance.
Returns
true if o is a T:System.Guid that has the same value as this instance; otherwise, false.

Definition at line 986 of file Guid.cs.

◆ Equals() [2/2]

bool System.Guid.Equals ( Guid  g)

Returns a value indicating whether this instance and a specified T:System.Guid object represent the same value.

Parameters
gAn object to compare to this instance.
Returns
true if g is equal to this instance; otherwise, false.

Definition at line 1045 of file Guid.cs.

◆ GetHashCode()

override int System.Guid.GetHashCode ( )

Returns the hash code for this instance.

Returns
The hash code for this instance.

Definition at line 976 of file Guid.cs.

◆ NewGuid()

static Guid System.Guid.NewGuid ( )
static

Initializes a new instance of the T:System.Guid structure.

Returns
A new GUID object.

Definition at line 1289 of file Guid.cs.

◆ operator !=()

static bool System.Guid.operator != ( Guid  a,
Guid  b 
)
static

Indicates whether the values of two specified T:System.Guid objects are not equal.

Parameters
aThe first object to compare.
bThe second object to compare.
Returns
true if a and b are not equal; otherwise, false.

Definition at line 1280 of file Guid.cs.

◆ operator==()

static bool System.Guid.operator== ( Guid  a,
Guid  b 
)
static

Indicates whether the values of two specified T:System.Guid objects are equal.

Parameters
aThe first object to compare.
bThe second object to compare.
Returns
true if a and b are equal; otherwise, false.

Definition at line 1225 of file Guid.cs.

◆ Parse()

static Guid System.Guid.Parse ( string  input)
static

Converts the string representation of a GUID to the equivalent T:System.Guid structure.

Parameters
inputThe string to convert.
Returns
A structure that contains the value that was parsed.
Exceptions
T:System.ArgumentNullExceptioninput is null.
T:System.FormatExceptioninput is not in a recognized format.

Definition at line 302 of file Guid.cs.

◆ ParseExact()

static Guid System.Guid.ParseExact ( string  input,
string  format 
)
static

Converts the string representation of a GUID to the equivalent T:System.Guid structure, provided that the string is in the specified format.

Parameters
inputThe GUID to convert.
formatOne of the following specifiers that indicates the exact format to use when interpreting input : "N", "D", "B", "P", or "X".
Returns
A structure that contains the value that was parsed.
Exceptions
T:System.ArgumentNullExceptioninput or format is null.
T:System.FormatExceptioninput is not in the format specified by format .

Definition at line 345 of file Guid.cs.

◆ ToByteArray()

byte [] System.Guid.ToByteArray ( )

Returns a 16-element byte array that contains the value of this instance.

Returns
A 16-element byte array.

Definition at line 940 of file Guid.cs.

◆ ToString() [1/3]

override string System.Guid.ToString ( )

Returns a string representation of the value of this instance in registry format.

Returns
The value of this T:System.Guid, formatted by using the "D" format specifier as follows: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 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 M:System.String.ToUpper method on the returned string.

Definition at line 968 of file Guid.cs.

◆ ToString() [2/3]

string System.Guid.ToString ( string  format)

Returns a string representation of the value of this T:System.Guid instance, according to the provided format specifier.

Parameters
formatA single format specifier that indicates how to format the value of this T:System.Guid. The format parameter can be "N", "D", "B", "P", or "X". If format is null or an empty string (""), "D" is used.
Returns
The value of this T:System.Guid, represented as a series of lowercase hexadecimal digits in the specified format.
Exceptions
T:System.FormatExceptionThe value of format is not null, an empty string (""), "N", "D", "B", "P", or "X".

Definition at line 1300 of file Guid.cs.

◆ ToString() [3/3]

unsafe string System.Guid.ToString ( string  format,
IFormatProvider  provider 
)

Returns a string representation of the value of this instance of the T:System.Guid class, according to the provided format specifier and culture-specific format information.

Parameters
formatA single format specifier that indicates how to format the value of this T:System.Guid. The format parameter can be "N", "D", "B", "P", or "X". If format is null or an empty string (""), "D" is used.
provider(Reserved) An object that supplies culture-specific formatting information.
Returns
The value of this T:System.Guid, represented as a series of lowercase hexadecimal digits in the specified format.
Exceptions
T:System.FormatExceptionThe value of format is not null, an empty string (""), "N", "D", "B", "P", or "X".

Implements System.IFormattable.

Definition at line 1344 of file Guid.cs.

◆ TryParse()

static bool System.Guid.TryParse ( string  input,
out Guid  result 
)
static

Converts the string representation of a GUID to the equivalent T:System.Guid structure.

Parameters
inputThe GUID to convert.
resultThe structure that will contain the parsed value. If the method returns true, result contains a valid T:System.Guid. If the method returns false, result equals F:System.Guid.Empty.
Returns
true if the parse operation was successful; otherwise, false.

Definition at line 323 of file Guid.cs.

◆ TryParseExact()

static bool System.Guid.TryParseExact ( string  input,
string  format,
out Guid  result 
)
static

Converts the string representation of a GUID to the equivalent T:System.Guid structure, provided that the string is in the specified format.

Parameters
inputThe GUID to convert.
formatOne of the following specifiers that indicates the exact format to use when interpreting input : "N", "D", "B", "P", or "X".
resultThe structure that will contain the parsed value. If the method returns true, result contains a valid T:System.Guid. If the method returns false, result equals F:System.Guid.Empty.
Returns
true if the parse operation was successful; otherwise, false.

Definition at line 401 of file Guid.cs.

Member Data Documentation

◆ Empty

readonly Guid System.Guid.Empty
static

A read-only instance of the T:System.Guid structure whose value is all zeros.

Definition at line 126 of file Guid.cs.


The documentation for this struct was generated from the following file: