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
Post a Comment