user1360113
user1360113

Reputation:

What is the VB equivalent to this C# code?

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

Answers (2)

Li0liQ
Li0liQ

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

David Heffernan
David Heffernan

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

Related Questions