When I see a form function call:
Dim i as Integer = getAnInteger("I am groot")
I can understand that the signature getAnIntegershould be something like
Function getAnInteger(inp As String) As Integer
Now I have this call:
Property Name As String
Get
Return _name
End Get
Set(ByVal value as String)
_name = value
doSomething(Function() Name) '<---- this one
End Set
End Property
I realized that it doSomethingshould be defined as
Sub doSomething(ByVal fnName As Func(Of String))
'
' or
'
Sub doSomething(Of T)(ByVal fnName As Func(Of T)) '....................(1)
I found out that it
Sub doSomething(Of T)(ByVal fnName As Expression(Of Func(Of T))) '.....(2)
Question
How is it that Func(Of T)they Expression(Of Func(Of T))can take an argument Function() Name, where Nameis a property of type String. Also Expressionlocated in the namespace Linq. So the argument must be a linq expression. But Function() Namenot Linq! this is a simple delegate for a property Name. So how does it work?
source
share