I'm in a case where I would like to have a method that can take other methods as input.
The input method will always have a single object as input, but the objects are different.
This is more or less what i need to be able to do:
public static void takeAnything(Action<object> inputFunc)
{
Console.WriteLine(inputFunc.Method.Name);
}
public static void test1(MyOwnObject input){
// Do stuff with input object
}
public static void test2(MyOtherOwnObject input){
// Do stuff with input object
}
public static void startSystem(){
takeAnything(test1);
takeAnything(test2);
}
Which in this dummy case would write out:
test1
test2
I just cant't get this to work, so any help would be very much appreciated.
EDIT
I do not know if this is possible, maybe it is not, but it is important that the call is just takeAnything(test1)
, not takeAnything<MyOwnObject>(test1)
or anything else.