Skip to content
67 changes: 46 additions & 21 deletions xml/System/Guid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Guid" /> structure.</summary>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks

[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]

]]></format>
</remarks>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
Expand Down Expand Up @@ -242,7 +251,7 @@
## Examples
The following example passes each string listed in the Remarks section to the <xref:System.Guid.%23ctor%28System.String%29> constructor.

[!code-csharp[System.Guid.ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.ctor/cs/ctor1.cs#1)]
[!code-csharp-interactive[System.Guid.ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.ctor/cs/ctor1.cs#1)]
[!code-vb[System.Guid.ctor#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.guid.ctor/vb/ctor1.vb#1)]

]]></format>
Expand Down Expand Up @@ -374,7 +383,7 @@
## Examples
The following example creates a GUID whose string representation is "0000000a-000b-000c-0001-020304050607".

[!code-csharp[System.Guid.Ctor#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.ctor/cs/ctor2.cs#2)]
[!code-csharp-interactive[System.Guid.Ctor#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.ctor/cs/ctor2.cs#2)]
[!code-vb[System.Guid.Ctor#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.guid.ctor/vb/ctor2.vb#2)]

]]></format>
Expand Down Expand Up @@ -688,7 +697,9 @@
## Remarks
You can compare a GUID with the value of the <xref:System.Guid.Empty?displayProperty=nameWithType> field to determine whether a GUID is non-zero. The following example uses the <xref:System.Guid.op_Equality%2A> operator to compare two GUID values with <xref:System.Guid.Empty?displayProperty=nameWithType> to determine whether they consist exclusively of zeros.

[!code-csharp[System.Guid.Empty#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.empty/cs/empty.cs#1)]
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]

[!code-csharp-interactive[System.Guid.Empty#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.empty/cs/empty.cs#1)]
[!code-vb[System.Guid.Empty#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.guid.empty/vb/empty.vb#1)]

]]></format>
Expand Down Expand Up @@ -905,7 +916,9 @@
## Examples
The following code example creates and displays the values of two <xref:System.Guid> objects.

[!code-csharp[system.guid.newguid#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.newguid/cs/ng.cs#1)]
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]

[!code-csharp-interactive[system.guid.newguid#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.newguid/cs/ng.cs#1)]
[!code-vb[system.guid.newguid#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.guid.newguid/vb/ng.vb#1)]

]]></format>
Expand Down Expand Up @@ -960,7 +973,9 @@
## Examples
The following example uses the <xref:System.Guid.op_Equality%2A> operator to compare two GUID values with <xref:System.Guid.Empty?displayProperty=nameWithType> to determine whether they consist exclusively of zeros.

[!code-csharp[System.Guid.Empty#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.empty/cs/empty.cs#1)]
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]

[!code-csharp-interactive[System.Guid.Empty#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.empty/cs/empty.cs#1)]
[!code-vb[System.Guid.Empty#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.guid.empty/vb/empty.vb#1)]

]]></format>
Expand Down Expand Up @@ -1014,7 +1029,7 @@
</remarks>
</Docs>
</Member>
<Member MemberName="Parse">
<MemberGroup MemberName="Parse">
<MemberSignature Language="C#" Value="public static Guid Parse (ReadOnlySpan&lt;char&gt; input);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig valuetype System.Guid Parse(valuetype System.ReadOnlySpan`1&lt;char&gt; input) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Guid.Parse(System.ReadOnlySpan{System.Char})" />
Expand Down Expand Up @@ -1070,6 +1085,8 @@ The method throws a <xref:System.FormatException> if it is unable to successfull

Use the <xref:System.Guid.TryParse%2A> method to catch any unsuccessful parse operations without having to handle an exception.

[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]

]]></format>
</remarks>
<exception cref="T:System.FormatException">
Expand All @@ -1080,7 +1097,7 @@ Use the <xref:System.Guid.TryParse%2A> method to catch any unsuccessful parse op
After trimming, the length of the read-only character span is 0.
</exception>
</Docs>
</Member>
</MemberGroup>
<Member MemberName="Parse">
<MemberSignature Language="C#" Value="public static Guid Parse (string input);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig valuetype System.Guid Parse(string input) cil managed" />
Expand Down Expand Up @@ -1144,12 +1161,10 @@ After trimming, the length of the read-only character span is 0.

Use the <xref:System.Guid.TryParse%2A> method to catch any unsuccessful parse operations without having to handle an exception.



## Examples
The following example creates a new GUID, converts it to three separate string representations by calling the <xref:System.Guid.ToString%28System.String%29> method with the "B", "D", and "X" format specifiers, and then calls the <xref:System.Guid.Parse%2A> method to convert the strings back to <xref:System.Guid> values.

[!code-csharp[System.Guid.Parse#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.parse/cs/parseex1.cs#3)]
[!code-csharp-interactive[System.Guid.Parse#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.parse/cs/parseex1.cs#3)]
[!code-vb[System.Guid.Parse#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.guid.parse/vb/parseex1.vb#3)]

]]></format>
Expand All @@ -1162,7 +1177,7 @@ After trimming, the length of the read-only character span is 0.
<altmember cref="M:System.Guid.ToString" />
</Docs>
</Member>
<Member MemberName="ParseExact">
<MemberGroup MemberName="ParseExact">
<MemberSignature Language="C#" Value="public static Guid ParseExact (ReadOnlySpan&lt;char&gt; input, ReadOnlySpan&lt;char&gt; format);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig valuetype System.Guid ParseExact(valuetype System.ReadOnlySpan`1&lt;char&gt; input, valuetype System.ReadOnlySpan`1&lt;char&gt; format) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Guid.ParseExact(System.ReadOnlySpan{System.Char},System.ReadOnlySpan{System.Char})" />
Expand Down Expand Up @@ -1208,10 +1223,12 @@ The <xref:System.Guid.ParseExact%2A> method requires the read-only character spa
|P|32 digits separated by hyphens, enclosed in parentheses:<br /><br /> (00000000-0000-0000-0000-000000000000)|
|X|Four hexadecimal values enclosed in braces, where the fourth value is a subset of eight hexadecimal values that is also enclosed in braces:<br /><br /> {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}|

[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]

]]></format>
</remarks>
</Docs>
</Member>
</MemberGroup>
<Member MemberName="ParseExact">
<MemberSignature Language="C#" Value="public static Guid ParseExact (string input, string format);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig valuetype System.Guid ParseExact(string input, string format) cil managed" />
Expand Down Expand Up @@ -1265,12 +1282,10 @@ The <xref:System.Guid.ParseExact%2A> method requires the read-only character spa
|P|32 digits separated by hyphens, enclosed in parentheses:<br /><br /> (00000000-0000-0000-0000-000000000000)|
|X|Four hexadecimal values enclosed in braces, where the fourth value is a subset of eight hexadecimal values that is also enclosed in braces:<br /><br /> {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}|



## Examples
The following example calls the <xref:System.Guid.ToString%28System.String%29> method with each of the supported format specifiers to generate an array of strings that represent a single GUID. These are then passed to the <xref:System.Guid.ParseExact%2A> method, which successfully parses only the string that conforms to the "B" format specifier.

[!code-csharp[System.Guid.Parse#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.parse/cs/parseexactex1.cs#4)]
[!code-csharp-interactive[System.Guid.Parse#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.parse/cs/parseexactex1.cs#4)]
[!code-vb[System.Guid.Parse#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.guid.parse/vb/parseexactex1.vb#4)]

]]></format>
Expand Down Expand Up @@ -1450,7 +1465,9 @@ Because the `provider` parameter is ignored, you cannot use it to provide a cust
## Examples
The following example calls the <xref:System.Guid.NewGuid%2A> method to create a <xref:System.Guid> value, and then calls the <xref:System.Guid.ToByteArray%2A> method to represent the <xref:System.Guid> value as a byte array. It then displays both values to the console. Finally, it instantiates a new <xref:System.Guid> value from the byte array and calls its <xref:System.Guid.Equals%28System.Guid%29> method to show that the two <xref:System.Guid> values are identical.

[!code-csharp[System.Guid.ToByteArray#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.tobytearray/cs/tobytearray3.cs#1)]
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]

[!code-csharp-interactive[System.Guid.ToByteArray#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.tobytearray/cs/tobytearray3.cs#1)]
[!code-vb[System.Guid.ToByteArray#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.guid.tobytearray/vb/tobytearray3.vb#1)]

]]></format>
Expand Down Expand Up @@ -1686,7 +1703,7 @@ Because the `provider` parameter is ignored, you cannot use it to provide a cust
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="TryParse">
<MemberGroup MemberName="TryParse">
<MemberSignature Language="C#" Value="public static bool TryParse (ReadOnlySpan&lt;char&gt; input, out Guid result);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig bool TryParse(valuetype System.ReadOnlySpan`1&lt;char&gt; input, [out] valuetype System.Guid&amp; result) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Guid.TryParse(System.ReadOnlySpan{System.Char},System.Guid@)" />
Expand Down Expand Up @@ -1718,9 +1735,15 @@ Because the `provider` parameter is ignored, you cannot use it to provide a cust
<summary>Converts the specified read-only span of characters containing the representation of a GUID to the equivalent <see cref="T:System.Guid" /> structure.</summary>
<returns>
<see langword="true" /> if the parse operation was successful; otherwise, <see langword="false" />.</returns>
<remarks>To be added.</remarks>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]
]]></format>
</remarks>
</Docs>
</Member>
</MemberGroup>
<Member MemberName="TryParse">
<MemberSignature Language="C#" Value="public static bool TryParse (string input, out Guid result);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig bool TryParse(string input, [out] valuetype System.Guid&amp; result) cil managed" />
Expand Down Expand Up @@ -1780,7 +1803,7 @@ Because the `provider` parameter is ignored, you cannot use it to provide a cust
## Examples
The following example creates a new GUID, converts it to three separate string representations by calling the <xref:System.Guid.ToString%28System.String%29> method with the "B", "D", and "X" format specifiers, and then calls the <xref:System.Guid.TryParse%2A> method to convert the strings back to <xref:System.Guid> values.

[!code-csharp[System.Guid.Parse#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.parse/cs/tryparseex1.cs#2)]
[!code-csharp-interactive[System.Guid.Parse#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.parse/cs/tryparseex1.cs#2)]
[!code-vb[System.Guid.Parse#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.guid.parse/vb/tryparseex1.vb#2)]

]]></format>
Expand Down Expand Up @@ -1888,7 +1911,9 @@ Because the `provider` parameter is ignored, you cannot use it to provide a cust
## Examples
The following example calls the <xref:System.Guid.ToString%28System.String%29> method with each of the supported format specifiers to generate an array of strings that represent a single GUID. These are then passed to the <xref:System.Guid.TryParseExact%2A> method, which successfully parses the string that conforms to the "B" format specifier.

[!code-csharp[System.Guid.Parse#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.parse/cs/tryparseexactex1.cs#5)]
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]

[!code-csharp-interactive[System.Guid.Parse#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.guid.parse/cs/tryparseexactex1.cs#5)]
[!code-vb[System.Guid.Parse#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.guid.parse/vb/tryparseexactex1.vb#5)]

]]></format>
Expand Down