Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to directly get the TResult of a Func of including lambda expression?

Status
Not open for further replies.

WomanPro

Programmer
Nov 1, 2012
180
GR
I would like to ask something please.
Supposing the following expression Dim ExistsPosValue1 As Func(Of GatesPositions, Boolean) = Function(p) p.pos = 3 how can I get with only a statement the returning value (true - false). I can do it with the following but I would like something directly than that? Any explanations please? Thank you so much in advanced. Any help will be much appreciated.

Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Chck()
End Sub

Public Sub CheckFuncOf(ByVal ExistsPosValue1 As Func(Of GatesPositions, Boolean), ByVal GtPos As GatesPositions?)

Dim Flg As Boolean

If ExistsPosValue1.Invoke(GtPos) Then

Flg = True

End If

End Sub

Public Sub Chck()

Dim ExistsPosValue1 As Func(Of GatesPositions, Boolean) = Function(p) p.pos = 3

Dim GtPos As GatesPositions? = PcCheckerGates.First(Function(x) x.pos = 3)

CheckFuncOf(ExistsPosValue1, GtPos)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top