Action(Of T) Lambdas in VB

Until VB catches up with C# in the lambda support realm, here is how you can accomplish those Moq or Rhino.Mocks style verifications in VB:

dim someSub as Action(Of double) = AddressOf mockObject.SomeSub
Rhino.Mocks.Expect.Call( someSub)

It’s very frustrating going from the full support in C# to VB, but I’m finding sufficient workaround for most items.  I shouldn’t be so hard on VB.  C# doesn’t support inline of Xml which is pretty friggin’ sweet.

Published 03-30-2009 3:49 PM by cromwellryan
Filed under:

Comments

# cromwellryan said on 31 March, 2009 03:29 PM

After seeing that title again, it should say "kinda".  These are obviously not lambda expressions, but simply a way to take advantage of some of the nice support for delegate invokation in some Mocking Frameworks.