Skip to content

Commit f27a288

Browse files
authored
.NET Interactive: Add_try_dotnet_to_batch_28 (dotnet#5187)
* add_try_dotnet_to_batch_28a * add_try_dotnet_to_batch_28b * add_try_dotnet_batch_28c * fixes * second_sample_enabled
1 parent 39bbf6f commit f27a288

File tree

14 files changed

+147
-295
lines changed

14 files changed

+147
-295
lines changed

xml/System.Globalization/NumberFormatInfo.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,10 +1634,10 @@
16341634
## Examples
16351635
The following example demonstrates the effect of changing the <xref:System.Globalization.NumberFormatInfo.NumberDecimalDigits%2A> property.
16361636
1637-
[!code-cpp[NumberDecimalDigits#1](~/samples/snippets/cpp/VS_Snippets_CLR/NumberDecimalDigits/CPP/numberdecimaldigits.cpp#1)]
1638-
[!code-csharp[NumberDecimalDigits#1](~/samples/snippets/csharp/VS_Snippets_CLR/NumberDecimalDigits/CS/numberdecimaldigits.cs#1)]
1639-
[!code-vb[NumberDecimalDigits#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/NumberDecimalDigits/VB/numberdecimaldigits.vb#1)]
1640-
1637+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/NumberDecimalDigits/CPP/numberdecimaldigits.cpp" id="Snippet1":::
1638+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/NumberDecimalDigits/CS/numberdecimaldigits.cs" interactive="try-dotnet" id="Snippet1":::
1639+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/NumberDecimalDigits/VB/numberdecimaldigits.vb" id="Snippet1":::
1640+
16411641
]]></format>
16421642
</remarks>
16431643
<exception cref="T:System.ArgumentOutOfRangeException">The property is being set to a value that is less than 0 or greater than 99.</exception>

xml/System.Globalization/RegionInfo.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@
9393
## Examples
9494
The following example demonstrates several members of the <xref:System.Globalization.RegionInfo> class.
9595
96-
[!code-cpp[System.Globalization.RegionInfo#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CPP/regioninfo.cpp#1)]
97-
[!code-csharp[System.Globalization.RegionInfo#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CS/regioninfo.cs#1)]
98-
[!code-vb[System.Globalization.RegionInfo#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo/VB/regioninfo.vb#1)]
99-
96+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CPP/regioninfo.cpp" id="Snippet1":::
97+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CS/regioninfo.cs" interactive="try-dotnet" id="Snippet1":::
98+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo/VB/regioninfo.vb" id="Snippet1":::
99+
100100
]]></format>
101101
</remarks>
102102
<altmember cref="T:System.Globalization.CultureInfo" />

xml/System.Globalization/UnicodeCategory.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@
8383
## Examples
8484
The following example displays the characters and their corresponding code points for characters in the UppercaseLetter category. You can modify the example to display the letters in any other category by replacing UppercaseLetter with the category of interest to you in the assignment to the `category` variable. Note that the output for some categories can be extensive.
8585
86-
[!code-csharp[System.Globalization.UnicodeCategory#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Globalization.UnicodeCategory/cs/Characters1.cs#1)]
87-
[!code-vb[System.Globalization.UnicodeCategory#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Globalization.UnicodeCategory/vb/Characters1.vb#1)]
88-
86+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Globalization.UnicodeCategory/cs/Characters1.cs" id="Snippet1":::
87+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Globalization.UnicodeCategory/vb/Characters1.vb" id="Snippet1":::
88+
8989
]]></format>
9090
</remarks>
9191
<altmember cref="T:System.Text.UnicodeEncoding" />

xml/System.Linq/Enumerable.xml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,9 +2866,9 @@ Dim doubles = From item As Integer In sequence
28662866
## Examples
28672867
The following code example demonstrates how to use <xref:System.Linq.Enumerable.ElementAtOrDefault%2A>. This example uses an index that is outside the bounds of the array.
28682868

2869-
[!code-csharp[System.Linq.Enumerable#29](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs#29)]
2870-
[!code-vb[System.Linq.Enumerable#29](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb#29)]
2871-
2869+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs" interactive="try-dotnet-method" id="Snippet29":::
2870+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb" id="Snippet29":::
2871+
28722872
]]></format>
28732873
</remarks>
28742874
<exception cref="T:System.ArgumentNullException">
@@ -4753,14 +4753,14 @@ Only unique elements are returned.
47534753
## Examples
47544754
The following code example demonstrates how to use <xref:System.Linq.Enumerable.LastOrDefault%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%29> on an empty array.
47554755

4756-
[!code-csharp[System.Linq.Enumerable#45](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs#45)]
4757-
[!code-vb[System.Linq.Enumerable#45](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb#45)]
4758-
4756+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs" interactive="try-dotnet-method" id="Snippet45":::
4757+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb" id="Snippet45":::
4758+
47594759
Sometimes the value of `default(TSource)` is not the default value that you want to use if the collection contains no elements. Instead of checking the result for the unwanted default value and then changing it if necessary, you can use the <xref:System.Linq.Enumerable.DefaultIfEmpty%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%2C%60%600%29> method to specify the default value that you want to use if the collection is empty. Then, call <xref:System.Linq.Enumerable.Last%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%29> to obtain the last element. The following code example uses both techniques to obtain a default value of 1 if a collection of numeric days of the month is empty. Because the default value for an integer is 0, which does not correspond to any day of the month, the default value must be specified as 1 instead. The first result variable is checked for the unwanted default value after the query has finished executing. The second result variable is obtained by using <xref:System.Linq.Enumerable.DefaultIfEmpty%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%2C%60%600%29> to specify a default value of 1.
47604760

4761-
[!code-csharp[System.Linq.Enumerable#127](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs#127)]
4762-
[!code-vb[System.Linq.Enumerable#127](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb#127)]
4763-
4761+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs" interactive="try-dotnet-method" id="Snippet127":::
4762+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb" id="Snippet127":::
4763+
47644764
]]></format>
47654765
</remarks>
47664766
<exception cref="T:System.ArgumentNullException">
@@ -4824,9 +4824,9 @@ Only unique elements are returned.
48244824
## Examples
48254825
The following code example demonstrates how to use <xref:System.Linq.Enumerable.LastOrDefault%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%2CSystem.Func%7B%60%600%2CSystem.Boolean%7D%29> by passing in a predicate. In the second call to the method, there is no element in the sequence that satisfies the condition.
48264826

4827-
[!code-csharp[System.Linq.Enumerable#46](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs#46)]
4828-
[!code-vb[System.Linq.Enumerable#46](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb#46)]
4829-
4827+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs" interactive="try-dotnet-method" id="Snippet46":::
4828+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb" id="Snippet46":::
4829+
48304830
]]></format>
48314831
</remarks>
48324832
<exception cref="T:System.ArgumentNullException">
@@ -4899,9 +4899,9 @@ Only unique elements are returned.
48994899
## Examples
49004900
The following code example demonstrates how to use <xref:System.Linq.Enumerable.LongCount%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%29> to count the elements in an array.
49014901

4902-
[!code-csharp[System.Linq.Enumerable#47](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs#47)]
4903-
[!code-vb[System.Linq.Enumerable#47](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb#47)]
4904-
4902+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs" interactive="try-dotnet-method" id="Snippet47":::
4903+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb" id="Snippet47":::
4904+
49054905
]]></format>
49064906
</remarks>
49074907
<exception cref="T:System.ArgumentNullException">
@@ -4967,9 +4967,9 @@ Only unique elements are returned.
49674967
## Examples
49684968
The following code example demonstrates how to use <xref:System.Linq.Enumerable.LongCount%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%2CSystem.Func%7B%60%600%2CSystem.Boolean%7D%29> to count the elements in an array that satisfy a condition.
49694969

4970-
[!code-csharp[System.Linq.Enumerable#48](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs#48)]
4971-
[!code-vb[System.Linq.Enumerable#48](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb#48)]
4972-
4970+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs" id="Snippet48":::
4971+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb" id="Snippet48":::
4972+
49734973
]]></format>
49744974
</remarks>
49754975
<exception cref="T:System.ArgumentNullException">
@@ -8395,9 +8395,9 @@ Only unique elements are returned.
83958395
## Examples
83968396
The following code example demonstrates how to use <xref:System.Linq.Enumerable.Prepend%2A> to prepend a value to the beginning of the sequence.
83978397

8398-
[!code-csharp[System.Linq.Enumerable#202](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs#202)]
8399-
[!code-vb[System.Linq.Enumerable#202](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb#202)]
8400-
8398+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs" interactive="try-dotnet-method" id="Snippet202":::
8399+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb" id="Snippet202":::
8400+
84018401
]]></format>
84028402
</remarks>
84038403
<exception cref="T:System.ArgumentNullException">
@@ -8587,9 +8587,9 @@ Only unique elements are returned.
85878587
## Examples
85888588
The following code example demonstrates how to use <xref:System.Linq.Enumerable.Reverse%2A> to reverse the order of elements in an array.
85898589

8590-
[!code-csharp[System.Linq.Enumerable#74](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs#74)]
8591-
[!code-vb[System.Linq.Enumerable#74](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb#74)]
8592-
8590+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs" interactive="try-dotnet-method" id="Snippet74":::
8591+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb" id="Snippet74":::
8592+
85938593
]]></format>
85948594
</remarks>
85958595
<exception cref="T:System.ArgumentNullException">
@@ -9732,9 +9732,9 @@ If `count` is not a positive number, this method returns an identical copy of th
97329732
## Examples
97339733
The following code example demonstrates how to use <xref:System.Linq.Enumerable.SkipWhile%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%2CSystem.Func%7B%60%600%2CSystem.Boolean%7D%29> to skip elements of an array as long as a condition is true.
97349734

9735-
[!code-csharp[System.Linq.Enumerable#88](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs#88)]
9736-
[!code-vb[System.Linq.Enumerable#88](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb#88)]
9737-
9735+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs" interactive="try-dotnet-method" id="Snippet88":::
9736+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb" id="Snippet88":::
9737+
97389738
]]></format>
97399739
</remarks>
97409740
<exception cref="T:System.ArgumentNullException">
@@ -9807,9 +9807,9 @@ If `count` is not a positive number, this method returns an identical copy of th
98079807
## Examples
98089808
The following code example demonstrates how to use <xref:System.Linq.Enumerable.SkipWhile%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%2CSystem.Func%7B%60%600%2CSystem.Int32%2CSystem.Boolean%7D%29> to skip elements of an array as long as a condition that depends on the element's index is true.
98099809

9810-
[!code-csharp[System.Linq.Enumerable#89](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs#89)]
9811-
[!code-vb[System.Linq.Enumerable#89](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb#89)]
9812-
9810+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Enumerable/CS/enumerable.cs" interactive="try-dotnet-method" id="Snippet89":::
9811+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Enumerable/VB/Enumerable.vb" id="Snippet89":::
9812+
98139813
]]></format>
98149814
</remarks>
98159815
<exception cref="T:System.ArgumentNullException">

xml/System.Linq/IGrouping`2.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@
129129
## Examples
130130
The following example demonstrates how to use the <xref:System.Linq.IGrouping%602.Key%2A> property to label each <xref:System.Linq.IGrouping%602> object in a sequence of <xref:System.Linq.IGrouping%602> objects. The <xref:System.Linq.Enumerable.GroupBy%60%602%28System.Collections.Generic.IEnumerable%7B%60%600%7D%2CSystem.Func%7B%60%600%2C%60%601%7D%29> method is used to obtain a sequence of <xref:System.Linq.IGrouping%602> objects. The `foreach` in Visual C# or `For Each` in Visual Basic loop then iterates through each <xref:System.Linq.IGrouping%602> object, outputting its key and the number of values it contains.
131131
132-
[!code-csharp[System.Linq.IGrouping#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.IGrouping/CS/igrouping.cs#2)]
133-
[!code-vb[System.Linq.IGrouping#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.IGrouping/VB/IGrouping.vb#2)]
134-
132+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.IGrouping/CS/igrouping.cs" interactive="try-dotnet-method" id="Snippet2":::
133+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.IGrouping/VB/IGrouping.vb" id="Snippet2":::
134+
135135
]]></format>
136136
</remarks>
137137
</Docs>

xml/System.Linq/IOrderedEnumerable`1.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@
5959
## Examples
6060
The following example demonstrates how to perform a primary and secondary ordering on an array of strings. It also demonstrates that the resulting <xref:System.Linq.IOrderedEnumerable%601> is enumerable.
6161
62-
[!code-csharp[System.Linq.IOrderedEnumerable#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.IOrderedEnumerable/CS/IOrderedEnumerable.cs#1)]
63-
[!code-vb[System.Linq.IOrderedEnumerable#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.IOrderedEnumerable/VB/IOrderedEnumerable.vb#1)]
62+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.IOrderedEnumerable/CS/IOrderedEnumerable.cs" interactive="try-dotnet-method" id="Snippet1":::
63+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.IOrderedEnumerable/VB/IOrderedEnumerable.vb" id="Snippet1":::
64+
6465
6566
]]></format>
6667
</remarks>
@@ -127,9 +128,9 @@
127128
## Examples
128129
The following code example demonstrates how to use <xref:System.Linq.IOrderedEnumerable`1.CreateOrderedEnumerable*> to perform a secondary ordering on an <xref:System.Linq.IOrderedEnumerable%601>.
129130
130-
[!code-csharp[System.Linq.IOrderedEnumerable#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.IOrderedEnumerable/CS/IOrderedEnumerable.cs#2)]
131-
[!code-vb[System.Linq.IOrderedEnumerable#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.IOrderedEnumerable/VB/IOrderedEnumerable.vb#2)]
132-
131+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.IOrderedEnumerable/CS/IOrderedEnumerable.cs" interactive="try-dotnet-method" id="Snippet2":::
132+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.IOrderedEnumerable/VB/IOrderedEnumerable.vb" id="Snippet2":::
133+
133134
]]></format>
134135
</remarks>
135136
</Docs>

0 commit comments

Comments
 (0)