I'm trying to make an IEnumerable extension similar to one shown in Using LINQ's Zip with a closure that doesn't return a value by @Hakakou, however I'm trying to modify it to run a method of the first value, with the second value as parameter.
For example:
public class MyObject {
private int myInt;
public MyObject(int a){
myInt = a;
}
public void addToFloat(int b){
myInt += b;
}
}
List<MyObject> objList = new List<ObjList> {new MyObj(5), new MyObj(8)};
List<int> intList = new List<int> {3, 1};
objList.MyExtension(intList, addToFloat)
// Now both MyObjects should have myInt set to 8 and 9 respectively
I'm not however sure how to 'separate' a method from the object and save its signature, then be able to apply it for each object instance with a given value.