Skip to content

Commit ea6728e

Browse files
v-mepamairaw
andauthored
.NET Interactive: Add_try_dotnet_batch_29 (dotnet#5265)
* add_try_dotnet_batch_29a * add_try_dotnet_to_batch_29b * add_try_dotnet_to_batch_29c * add_try_dotnet_to_batch_29d * Apply suggestions from code review * add_interactive_in_func_examples * Update xml/System.Linq/Enumerable.xml * Update xml/System.Linq/Enumerable.xml Co-authored-by: Maira Wenzel <[email protected]>
1 parent a0eaec0 commit ea6728e

File tree

12 files changed

+180
-419
lines changed

12 files changed

+180
-419
lines changed

xml/System.Globalization/DateTimeFormatInfo.xml

Lines changed: 36 additions & 36 deletions
Large diffs are not rendered by default.

xml/System.Linq/Enumerable.xml

Lines changed: 89 additions & 328 deletions
Large diffs are not rendered by default.

xml/System.Text.RegularExpressions/GroupCollection.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@
128128
129129
For each match, the <xref:System.Text.RegularExpressions.GroupCollection> contains three <xref:System.Text.RegularExpressions.Group> objects. The first object contains the string that matches the entire regular expression. The second object, which represents the first captured group, contains the product name. The third object, which represents the second captured group, contains the trademark or registered trademark symbol.
130130
131-
[!code-csharp[System.Text.RegularExpressions.GroupCollection#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.RegularExpressions.GroupCollection/cs/Example1.cs#1)]
132-
[!code-vb[System.Text.RegularExpressions.GroupCollection#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.GroupCollection/vb/Example1.vb#1)]
133-
131+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.RegularExpressions.GroupCollection/cs/Example1.cs" interactive="try-dotnet" id="Snippet1":::
132+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.GroupCollection/vb/Example1.vb" id="Snippet1":::
133+
134134
]]></format>
135135
</remarks>
136136
<altmember cref="T:System.Text.RegularExpressions.Group" />

xml/System.Text.RegularExpressions/Match.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
5656
If the <xref:System.Text.RegularExpressions.Regex.Match%2A?displayProperty=nameWithType> method fails to match the regular expression pattern, it returns a <xref:System.Text.RegularExpressions.Match> object that is equal to <xref:System.Text.RegularExpressions.Match.Empty%2A?displayProperty=nameWithType>. You can use the <xref:System.Text.RegularExpressions.Group.Success%2A> property to determine whether the match was successful. The following example provides an illustration.
5757
58-
[!code-csharp[System.Text.RegularExpressions.Match.Class#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/cs/Match1.cs#1)]
59-
[!code-vb[System.Text.RegularExpressions.Match.Class#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/vb/Match1.vb#1)]
58+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/cs/Match1.cs" interactive="try-dotnet-method" id="Snippet1":::
59+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/vb/Match1.vb" id="Snippet1":::
6060
6161
If a pattern match is successful, the <xref:System.Text.RegularExpressions.Capture.Value%2A> property contains the matched substring, the <xref:System.Text.RegularExpressions.Capture.Index%2A> property indicates the zero-based starting position of the matched substring in the input string, and the <xref:System.Text.RegularExpressions.Capture.Length%2A> property indicates the length of matched substring in the input string.
6262
@@ -82,16 +82,16 @@
8282
8383
The following example calls the <xref:System.Text.RegularExpressions.Regex.Matches%28System.String%2CSystem.String%29?displayProperty=nameWithType> method to retrieve all pattern matches in an input string. It then iterates the <xref:System.Text.RegularExpressions.Match> objects in the returned <xref:System.Text.RegularExpressions.MatchCollection> object to display information about each match.
8484
85-
[!code-csharp[System.Text.RegularExpressions.Match.Class#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/cs/Match2.cs#2)]
86-
[!code-vb[System.Text.RegularExpressions.Match.Class#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/vb/Match2.vb#2)]
87-
85+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/cs/Match2.cs" interactive="try-dotnet" id="Snippet2":::
86+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/vb/Match2.vb" id="Snippet2":::
87+
8888
**Example 2**
8989
9090
The following example calls the <xref:System.Text.RegularExpressions.Regex.Match%28System.String%2CSystem.String%29> and <xref:System.Text.RegularExpressions.Match.NextMatch%2A> methods to retrieve one match at a time.
9191
92-
[!code-csharp[System.Text.RegularExpressions.Match.Class#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/cs/Match3.cs#3)]
93-
[!code-vb[System.Text.RegularExpressions.Match.Class#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/vb/Match3.vb#3)]
94-
92+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/cs/Match3.cs" interactive="try-dotnet" id="Snippet3":::
93+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/vb/Match3.vb" id="Snippet3":::
94+
9595
]]></format>
9696
</remarks>
9797
<altmember cref="T:System.Text.RegularExpressions.MatchCollection" />

xml/System.Text.RegularExpressions/MatchCollection.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@
110110
## Examples
111111
The following example illustrates the use of the <xref:System.Text.RegularExpressions.MatchCollection> class to interrogate a set of <xref:System.Text.RegularExpressions.Match> instances.
112112
113-
[!code-cpp[Regex_Words#0](~/samples/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp#0)]
114-
[!code-csharp[Regex_Words#0](~/samples/snippets/csharp/VS_Snippets_CLR/Regex_Words/CS/words.cs#0)]
115-
[!code-vb[Regex_Words#0](~/samples/snippets/visualbasic/VS_Snippets_CLR/Regex_Words/VB/words.vb#0)]
116-
113+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp" id="Snippet0":::
114+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Regex_Words/CS/words.cs" interactive="try-dotnet" id="Snippet0":::
115+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Regex_Words/VB/words.vb" id="Snippet0":::
116+
117117
]]></format>
118118
</remarks>
119119
</Docs>

xml/System/Char.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5084,8 +5084,8 @@ This member is an explicit interface member implementation. It can be used only
50845084
## Examples
50855085
The following example converts each character in an array to its uppercase equivalent.
50865086
5087-
[!code-csharp[System.Char.ToUpper#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.char.toupper/cs/toupper1.cs#1)]
5088-
[!code-vb[System.Char.ToUpper#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.char.toupper/vb/toupper1.vb#1)]
5087+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.char.toupper/cs/toupper1.cs" interactive="try-dotnet" id="Snippet1":::
5088+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.char.toupper/vb/toupper1.vb" id="Snippet1":::
50895089
50905090
]]></format>
50915091
</remarks>
@@ -5154,8 +5154,8 @@ This member is an explicit interface member implementation. It can be used only
51545154
## Examples
51555155
The following example converts each character in an array to its uppercase equivalent for the en-US culture, the invariant culture, and the tr-TR culture. In this example, the uppercase equivalent of each lowercase letter is identical for all cultures except for one case. The lowercase "i" character (U+0069) converts to "I" (U+0049) in the en-US and invariant cultures, but to "İ" (U+0130) in the tr-TR culture.
51565156
5157-
[!code-csharp[System.Char.ToUpper#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.char.toupper/cs/toupper5.cs#2)]
5158-
[!code-vb[System.Char.ToUpper#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.char.toupper/vb/toupper5.vb#2)]
5157+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.char.toupper/cs/toupper5.cs" interactive="try-dotnet" id="Snippet2":::
5158+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.char.toupper/vb/toupper5.vb" id="Snippet2":::
51595159
51605160
]]></format>
51615161
</remarks>

xml/System/Decimal.xml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5121,9 +5121,9 @@
51215121
## Examples
51225122
The following example rounds a range of <xref:System.Decimal> values between 100 and 102 to the nearest integer. Because the method uses banker's rounding, note that 100.5 rounds to 100 and 101.5 rounds to 102.
51235123

5124-
[!code-csharp[System.Decimal.Round#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Decimal.Round/cs/Round1.cs#1)]
5125-
[!code-vb[System.Decimal.Round#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.Round/vb/Round1.vb#1)]
5126-
5124+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Decimal.Round/cs/Round1.cs" interactive="try-dotnet" id="Snippet1":::
5125+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.Round/vb/Round1.vb" id="Snippet1":::
5126+
51275127
]]></format>
51285128
</remarks>
51295129
<exception cref="T:System.OverflowException">The result is outside the range of a <see cref="T:System.Decimal" /> value.</exception>
@@ -5186,9 +5186,9 @@
51865186
## Examples
51875187
The following example rounds several `Decimal` values to a specified number of decimal places using the `Round` method.
51885188

5189-
[!code-csharp[System.Decimal.Round#12](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Decimal.Round/cs/Round12.cs#12)]
5190-
[!code-vb[System.Decimal.Round#12](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.Round/vb/Round12.vb#12)]
5191-
5189+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Decimal.Round/cs/Round12.cs" interactive="try-dotnet" id="Snippet12":::
5190+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.Round/vb/Round12.vb" id="Snippet12":::
5191+
51925192
]]></format>
51935193
</remarks>
51945194
<exception cref="T:System.ArgumentOutOfRangeException">
@@ -5263,9 +5263,9 @@
52635263
## Examples
52645264
The following example displays values returned by the <xref:System.Math.Round%28System.Decimal%29> method, the <xref:System.Math.Round%28System.Decimal%2CSystem.MidpointRounding%29> method with a `mode` argument of <xref:System.MidpointRounding.ToEven>, and the <xref:System.Math.Round%28System.Decimal%2CSystem.MidpointRounding%29> method with a `mode` argument of <xref:System.MidpointRounding.AwayFromZero>.
52655265

5266-
[!code-csharp[System.Math.Round.Overload#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.math.round.overload/cs/midpoint1.cs#5)]
5267-
[!code-vb[System.Math.Round.Overload#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.math.round.overload/vb/midpoint1.vb#5)]
5268-
5266+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.math.round.overload/cs/midpoint1.cs" interactive="try-dotnet-method" id="Snippet5":::
5267+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.math.round.overload/vb/midpoint1.vb" id="Snippet5":::
5268+
52695269
]]></format>
52705270
</remarks>
52715271
<exception cref="T:System.ArgumentException">
@@ -5343,10 +5343,10 @@
53435343
## Examples
53445344
The following example demonstrates how to use the <xref:System.Math.Round%28System.Decimal%2CSystem.Int32%2CSystem.MidpointRounding%29> method with the <xref:System.MidpointRounding> enumeration.
53455345

5346-
[!code-cpp[math.midpointrounding#1](~/samples/snippets/cpp/VS_Snippets_CLR/math.midpointrounding/cpp/mpr.cpp#1)]
5347-
[!code-csharp[math.midpointrounding#1](~/samples/snippets/csharp/VS_Snippets_CLR/math.midpointrounding/CS/mpr.cs#1)]
5348-
[!code-vb[math.midpointrounding#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/math.midpointrounding/VB/mpr.vb#1)]
5349-
5346+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/math.midpointrounding/cpp/mpr.cpp" id="Snippet1":::
5347+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/math.midpointrounding/CS/mpr.cs" interactive="try-dotnet-method" id="Snippet1":::
5348+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/math.midpointrounding/VB/mpr.vb" id="Snippet1":::
5349+
53505350
]]></format>
53515351
</remarks>
53525352
<exception cref="T:System.ArgumentOutOfRangeException">
@@ -7601,10 +7601,10 @@ This member is an explicit interface member implementation. It can be used only
76017601
## Examples
76027602
The following code example uses the `Truncate` method to discard the fractional digits of several `Decimal` values.
76037603

7604-
[!code-cpp[System.Decimal.Flr_Neg_Rnd_Trnc#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/CPP/floor_neg_trunc.cpp#1)]
7605-
[!code-csharp[System.Decimal.Flr_Neg_Rnd_Trnc#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/CS/floor_neg_trunc.cs#1)]
7606-
[!code-vb[System.Decimal.Flr_Neg_Rnd_Trnc#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/VB/floor_neg_trunc.vb#1)]
7607-
7604+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/CPP/floor_neg_trunc.cpp" id="Snippet1":::
7605+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/CS/floor_neg_trunc.cs" interactive="try-dotnet" id="Snippet1":::
7606+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/VB/floor_neg_trunc.vb" id="Snippet1":::
7607+
76087608
]]></format>
76097609
</remarks>
76107610
<altmember cref="M:System.Decimal.Round(System.Decimal,System.Int32)" />

xml/System/Exception.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,10 +1031,10 @@ Stack Trace:
10311031
## Examples
10321032
The following example demonstrates throwing and catching an exception that references an inner exception.
10331033
1034-
[!code-cpp[InnerEx#1](~/samples/snippets/cpp/VS_Snippets_CLR/InnerEx/CPP/innerex.cpp#1)]
1035-
[!code-csharp[InnerEx#1](~/samples/snippets/csharp/VS_Snippets_CLR/InnerEx/CS/innerex.cs#1)]
1036-
[!code-vb[InnerEx#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/InnerEx/VB/innerex.vb#1)]
1037-
1034+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/InnerEx/CPP/innerex.cpp" id="Snippet1":::
1035+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/InnerEx/CS/innerex.cs" interactive="try-dotnet" id="Snippet1":::
1036+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/InnerEx/VB/innerex.vb" id="Snippet1":::
1037+
10381038
]]></format>
10391039
</remarks>
10401040
</Docs>

xml/System/OutOfMemoryException.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ An <xref:System.OutOfMemoryException> exception has two major causes:
8484
8585
You are attempting to increase the length of a <xref:System.Text.StringBuilder> object beyond the size specified by its <xref:System.Text.StringBuilder.MaxCapacity%2A?displayProperty=nameWithType> property. The following example illustrates the <xref:System.OutOfMemoryException> exception thrown by a call to the <xref:System.Text.StringBuilder.Insert%28System.Int32%2CSystem.String%2CSystem.Int32%29?displayProperty=nameWithType> method when the example tries to insert a string that would cause the object's <xref:System.Text.StringBuilder.Length%2A> property to exceed its maximum capacity.
8686
87-
[!code-csharp[System.OutOfMemoryException#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.outofmemoryexception/cs/sb_example1.cs#1)]
88-
[!code-vb[System.OutOfMemoryException#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.outofmemoryexception/vb/sb_example1.vb#1)]
89-
87+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.outofmemoryexception/cs/sb_example1.cs" interactive="try-dotnet" id="Snippet1":::
88+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.outofmemoryexception/vb/sb_example1.vb" id="Snippet1":::
89+
9090
You can do either of the following to address the error:
9191
9292
- Replace the call to the <xref:System.Text.StringBuilder.%23ctor%28System.Int32%2CSystem.Int32%29?displayProperty=nameWithType> constructor with a call any other <xref:System.Text.StringBuilder> constructor overload. The maximum capacity of your <xref:System.Text.StringBuilder> object will be set to its default value, which is <xref:System.Int32.MaxValue?displayProperty=nameWithType>.

xml/System/String.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14246,9 +14246,9 @@ This member is an explicit interface member implementation. It can be used only
1424614246
## Examples
1424714247
The following example calls the <xref:System.String.ToUpper%2A> method to convert a series of one-character strings that contain each character in the Basic Latin, Latin-1 Supplement, and Latin Extended-A character sets. It then displays each string whose uppercase character is different from its lowercase character.
1424814248

14249-
[!code-cpp[System.String.ToUpper#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.String.ToUpper/cpp/ToUpperEx.cpp#1)]
14250-
[!code-csharp[System.String.ToUpper#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.String.ToUpper/cs/ToUpperEx.cs#1)]
14251-
[!code-vb[System.String.ToUpper#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.String.ToUpper/vb/ToUpperEx.vb#1)]
14249+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.String.ToUpper/cpp/ToUpperEx.cpp" id="Snippet1":::
14250+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.String.ToUpper/cs/ToUpperEx.cs" id="Snippet1":::
14251+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.String.ToUpper/vb/ToUpperEx.vb" id="Snippet1":::
1425214252

1425314253
]]></format>
1425414254
</remarks>
@@ -14319,8 +14319,8 @@ This member is an explicit interface member implementation. It can be used only
1431914319
## Examples
1432014320
The following example converts a string of lowercase characters to two strings of uppercase characters using the English-United States and Turkish-Turkey cultures, then compares the uppercase strings. The uppercase strings are identical except that for each occurrence of the Unicode LATIN CAPITAL LETTER I in one string, the other string contains LATIN CAPITAL LETTER I WITH DOT ABOVE.
1432114321

14322-
[!code-csharp[string.toupper1#1](~/samples/snippets/csharp/VS_Snippets_CLR/string.toupper1/CS/toupper.cs#1)]
14323-
[!code-vb[string.toupper1#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/string.toupper1/VB/toupper.vb#1)]
14322+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/string.toupper1/CS/toupper.cs" interactive="try-dotnet" id="Snippet1":::
14323+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/string.toupper1/VB/toupper.vb" id="Snippet1":::
1432414324

1432514325
]]></format>
1432614326
</remarks>

0 commit comments

Comments
 (0)