c# - Allow different parameters in action delegate -


i trying declare action-delegate allows set functions different paremeter.

here minimal example: have different void function this:

private void function1(string parameter) { ... } private void function2(int parameter) { ... } 

i want pass these functions in same constructor. not possible in way.

main {   aclass = new aclass(function1);   aclass b = new aclass(function2); } 

how need define action (object not working) - don't want overload consturcor!

public class aclass {   public aclass(action<???> function) { ... } } 

thank helping me!

typically either this:

public class aclass<t> {     public aclass(action<t> function) { ... } } 

...or overload constructor.

if have else in mind need provide more code show want do.


Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

formula - R: how to pass in a reference to the variable in glm or lm? -