Skip to content

Commit ccd05b0

Browse files
WilliamAntonRohmmairaw
authored andcommitted
updating for Try .NET (#3537)
1 parent 645dfb9 commit ccd05b0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

xml/System/Func`2.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@
7979
8080
The following example simplifies this code by instantiating the <xref:System.Func%602> delegate instead of explicitly defining a new delegate and assigning a named method to it.
8181
82-
[!code-csharp[System.Func~2#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Func~2/cs/Func2_1.cs#2)]
82+
[!code-csharp-interactive[System.Func~2#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Func~2/cs/Func2_1.cs#2)]
8383
[!code-vb[System.Func~2#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~2/vb/Func2_1.vb#2)]
8484
8585
You can also use the <xref:System.Func%602> delegate with anonymous methods in C#, as the following example illustrates. (For an introduction to anonymous methods, see [Anonymous Methods](~/docs/csharp/programming-guide/statements-expressions-operators/anonymous-methods.md).)
8686
87-
[!code-csharp[System.Func~2#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Func~2/cs/Anon.cs#3)]
87+
[!code-csharp-interactive[System.Func~2#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Func~2/cs/Anon.cs#3)]
8888
8989
You can also assign a lambda expression to a <xref:System.Func%602> delegate, as the following example illustrates. (For an introduction to lambda expressions, see [Lambda Expressions](~/docs/visual-basic/programming-guide/language-features/procedures/lambda-expressions.md) and [Lambda Expressions](~/docs/csharp/programming-guide/statements-expressions-operators/lambda-expressions.md).)
9090
91-
[!code-csharp[System.Func~2#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Func~2/cs/Lambda.cs#4)]
91+
[!code-csharp-interactive[System.Func~2#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Func~2/cs/Lambda.cs#4)]
9292
[!code-vb[System.Func~2#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~2/vb/Lambda.vb#4)]
9393
9494
The underlying type of a lambda expression is one of the generic `Func` delegates. This makes it possible to pass a lambda expression as a parameter without explicitly assigning it to a delegate. In particular, because many methods of types in the <xref:System.Linq> namespace have <xref:System.Func%602> parameters, you can pass these methods a lambda expression without explicitly instantiating a <xref:System.Func%602> delegate.
@@ -97,8 +97,10 @@
9797
9898
## Examples
9999
The following example demonstrates how to declare and use a <xref:System.Func%602> delegate. This example declares a <xref:System.Func%602> variable and assigns it a lambda expression that converts the characters in a string to uppercase. The delegate that encapsulates this method is subsequently passed to the <xref:System.Linq.Enumerable.Select%2A?displayProperty=nameWithType> method to change the strings in an array of strings to uppercase.
100-
101-
[!code-csharp[System.Func~2#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Func~2/cs/Example.cs#5)]
100+
101+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]
102+
103+
[!code-csharp-interactive[System.Func~2#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Func~2/cs/Example.cs#5)]
102104
[!code-vb[System.Func~2#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~2/vb/Example.vb#5)]
103105
104106
]]></format>

0 commit comments

Comments
 (0)