VB to C# conversion incongruency with lambdas
- by Jason
I have a bit of code that I have been tasked with converting to C# from VB. A snippet of mine seems like it cannot be converted from one to the other, and if so, I just don't know how to do it and am getting a little frustrated.
Here's some background:
OrderForm is an abstract class, inherited by Invoice (and also PurchaseOrder). The following VB snippet works correctly:
Dim Invs As List(Of OrderForm) = GetForms(theOrder.OrderID)
....
Dim inv As Invoice = Invs.Find(
Function(someInv As Invoice) thePO.SubPONumber = someInv.SubInvoiceNumber)
In C#, the best I came to converting this is:
List<OrderForm> Invs = GetForms(theOrder.OrderID);
....
Invoice inv = Invs.Find(
(Invoice someInv) => thePO.SubPONumber == someInv.SubInvoiceNumber);
However, I get the following error when I do this:
Cannot convert lambda expression to delegate type 'System.Predicate' because the parameter types do not match the delegate parameter types
Is there any way to fix this without restructuring my whole codebase?