diff --git a/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Delegate.fs b/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Delegate.fs
new file mode 100644
index 00000000000..f2e5239589b
--- /dev/null
+++ b/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Delegate.fs
@@ -0,0 +1,17 @@
+module Delegate
+
+//
+open System
+open System.Globalization
+
+type ParseNumber<'T> = delegate of (string * NumberStyles * IFormatProvider) -> 'T
+
+let numericString = "-1,234"
+let parser = ParseNumber Int32.Parse
+
+parser.Invoke(
+ numericString,
+ NumberStyles.Integer ||| NumberStyles.AllowThousands,
+ CultureInfo.InvariantCulture )
+|> printfn "%i"
+//
diff --git a/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Func4.fs b/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Func4.fs
new file mode 100644
index 00000000000..9b14520031e
--- /dev/null
+++ b/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Func4.fs
@@ -0,0 +1,19 @@
+module Func4
+
+//
+open System
+open System.Globalization
+
+let parseInt (str: string) styles format = Int32.Parse(str, styles, format)
+
+let numericString = "-1,234"
+
+let parser =
+ Func parseInt
+
+parser.Invoke(
+ numericString,
+ NumberStyles.Integer ||| NumberStyles.AllowThousands,
+ CultureInfo.InvariantCulture )
+|> printfn "%i"
+//
diff --git a/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Lambda.fs b/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Lambda.fs
new file mode 100644
index 00000000000..4a321e9bbcd
--- /dev/null
+++ b/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Lambda.fs
@@ -0,0 +1,15 @@
+module Lambda
+
+//
+open System
+open System.Globalization
+
+let numericString = "-1,234"
+let parser = Func(fun s sty p ->
+ Int32.Parse(s, sty, p))
+
+parser.Invoke(numericString,
+ NumberStyles.Integer ||| NumberStyles.AllowThousands,
+ CultureInfo.InvariantCulture)
+|> printfn "%i"
+//
\ No newline at end of file
diff --git a/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/fs.fsproj b/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/fs.fsproj
new file mode 100644
index 00000000000..86319fbd106
--- /dev/null
+++ b/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/fs.fsproj
@@ -0,0 +1,11 @@
+
+
+ Exe
+ net6.0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/xml/System/Func`4.xml b/xml/System/Func`4.xml
index 68567712d77..6318deeabd1 100644
--- a/xml/System/Func`4.xml
+++ b/xml/System/Func`4.xml
@@ -102,25 +102,28 @@
You can use this delegate to represent a method that can be passed as a parameter without explicitly declaring a custom delegate. The encapsulated method must correspond to the method signature that is defined by this delegate. This means that the encapsulated method must have three parameters, each of which is passed to it by value, and that it must return a value.
> [!NOTE]
-> To reference a method that has three parameters and returns `void` (or in Visual Basic, that is declared as a `Sub` rather than as a `Function`), use the generic delegate instead.
+> To reference a method that has three parameters and returns `void` (`unit` in F#) (or in Visual Basic, that is declared as a `Sub` rather than as a `Function`), use the generic delegate instead.
When you use the delegate, you do not have to explicitly define a delegate that encapsulates a method with three parameters. For example, the following code explicitly declares a generic delegate named `ParseNumber` and assigns a reference to the method to its delegate instance.
:::code language="csharp" source="~/samples/snippets/csharp/System/FuncT1,T2,T3,TResult/Overview/Delegate.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Delegate.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~4/vb/Delegate.vb" id="Snippet1":::
The following example simplifies this code by instantiating the delegate instead of explicitly defining a new delegate and assigning a named method to it.
:::code language="csharp" source="~/samples/snippets/csharp/System/FuncT1,T2,T3,TResult/Overview/Func4.cs" interactive="try-dotnet" id="Snippet2":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Func4.fs" id="Snippet2":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~4/vb/Func4.vb" id="Snippet2":::
You can use the delegate with anonymous methods in C#, as the following example illustrates. (For an introduction to anonymous methods, see [Anonymous Methods](/dotnet/csharp/programming-guide/statements-expressions-operators/anonymous-methods).)
:::code language="csharp" source="~/samples/snippets/csharp/System/FuncT1,T2,T3,TResult/Overview/Anon.cs" interactive="try-dotnet" id="Snippet3":::
- You can also assign a lambda expression to a delegate, as the following example illustrates. (For an introduction to lambda expressions, see [Lambda Expressions](/dotnet/visual-basic/programming-guide/language-features/procedures/lambda-expressions) and [Lambda Expressions](/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions).)
+ You can also assign a lambda expression to a delegate, as the following example illustrates. (For an introduction to lambda expressions, see [Lambda Expressions (VB)](/dotnet/visual-basic/programming-guide/language-features/procedures/lambda-expressions), [Lambda Expressions (C#)](/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions) and [Lambda Expressions (F#)](/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword).)
:::code language="csharp" source="~/samples/snippets/csharp/System/FuncT1,T2,T3,TResult/Overview/Lambda.cs" interactive="try-dotnet" id="Snippet4":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/System/FuncT1,T2,T3,TResult/Overview/Lambda.fs" id="Snippet4":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~4/vb/Lambda.vb" id="Snippet4":::
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 namespace have `Func` parameters, you can pass these methods a lambda expression without explicitly instantiating a `Func` delegate.
@@ -131,13 +134,16 @@
The following example demonstrates how to declare and use a delegate. This example declares a variable and assigns it a lambda expression that takes a value and an value as parameters. The lambda expression returns `true` if the length of the parameter is equal to the value of the parameter. The delegate that encapsulates this method is subsequently used in a query to filter strings in an array of strings.
:::code language="csharp" source="~/samples/snippets/csharp/System/FuncT1,T2,TResult/Overview/Example.cs" interactive="try-dotnet" id="Snippet5":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Func~3/fs/Example.fs" id="Snippet5":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~3/vb/Example.vb" id="Snippet5":::
]]>
Lambda Expressions (C# Programming Guide)
Lambda Expressions
+ Lambda Expressions: The fun Keyword (F#)
Delegates (C# Programming Guide)
+ Delegates (F#)
Delegates in Visual Basic