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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -