Skip to content

Guid.xml updates for Try .NET #3393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 17, 2020
55 changes: 38 additions & 17 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 @@ -241,8 +250,8 @@

## 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 @@ -1081,7 +1096,7 @@ After trimming, the length of the read-only character span is 0.
</exception>
</Docs>
</Member>
<Member MemberName="Parse">
<MemberGroup 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" />
<MemberSignature Language="DocId" Value="M:System.Guid.Parse(System.String)" />
Expand Down Expand Up @@ -1144,12 +1159,12 @@ 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.


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

## 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 @@ -1161,7 +1176,7 @@ After trimming, the length of the read-only character span is 0.
<altmember cref="M:System.Guid.TryParse(System.String,System.Guid@)" />
<altmember cref="M:System.Guid.ToString" />
</Docs>
</Member>
</MemberGroup>
<Member 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" />
Expand Down Expand Up @@ -1212,7 +1227,7 @@ The <xref:System.Guid.ParseExact%2A> method requires the read-only character spa
</remarks>
</Docs>
</Member>
<Member MemberName="ParseExact">
<MemberGroup 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" />
<MemberSignature Language="DocId" Value="M:System.Guid.ParseExact(System.String,System.String)" />
Expand Down Expand Up @@ -1265,12 +1280,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)]


## 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 All @@ -1281,7 +1296,7 @@ The <xref:System.Guid.ParseExact%2A> method requires the read-only character spa
<paramref name="input" /> is not in the format specified by <paramref name="format" />.</exception>
<altmember cref="M:System.Guid.TryParseExact(System.String,System.String,System.Guid@)" />
</Docs>
</Member>
</MemberGroup>
<Member MemberName="System.IComparable.CompareTo">
<MemberSignature Language="C#" Value="int IComparable.CompareTo (object value);" />
<MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance int32 System.IComparable.CompareTo(object value) cil managed" />
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 @@ -1780,7 +1797,9 @@ 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)]
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]

[!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 +1907,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