Reputation:
I have the following line in C#:
test.testMethod.Foreach(x => x.testMethod2.Add(test_arg));
What would be the equivalent in VB?
I tried to do x => x.testMethod2.Add
but it is not allowing me to.
Upvotes: 1
Views: 141
Reputation: 11264
This is called lambda expression.
An appropriate equivalent in vb.net will be
Sub(x) x.testMethod2.Add(test_arg)
You are basically using Function
in case you are are creating expression function and Sub
in case you are creating expression subroutine. See Lambda Expressions (Visual Basic) for more details.
Upvotes: 4
Reputation: 612794
It's a lambda expression. The VB equivalent to that C# lambda expression would be:
Sub(x) x.testMethod2.Add(test_arg)
Upvotes: 3