static void ExampleWithObjectParameterContainingMultipleMethods() { // Similar to example with lambda parameter, except we can now provide multiple behaviors (one for each method in the object parameter). // In essence, we send a group of "mini-programs" or "black boxes" to the other object/class. ObjectContainingMultipleMethods a = new ObjectContainingMultipleMethods(); ObjectReceivingObjectParameter b = new ObjectReceivingObjectParameter(a); }
public ObjectReceivingObjectParameter(ObjectContainingMultipleMethods o) { // Do something with the object's methods right away, for example: o.DoSomething(new Person { Name = "John Doe", Age = 40 }); o.DoSomethingElse("abc"); o.DoEvenMore(123); // Or store it for later use: otherObject = o; }