Wednesday, 15 May 2013

c# - Delegates with specific arguments -


I'll try to keep it as simple as I can. I have a delegate DEL which is a zero () (no argument). I have the function FUNC (int) I have two variables A and B. I want to be able to do A () and this is FUNC (10) < / Code>, and be able to do B () and it will run FUNC (43) . I know that I can be representative zero (int) , but I have a function FUNC2 (int, int) . And a variable that will run FUNC2 (21,6) . I need all the same types of variables of A, B and C.

It seems that you have it

  public representative zero DEL (); Public category {Public static zero FUNC} {} public static zero FUNC2 (int value 1, int value 2) {}}  

and you'll see variables A < / Code>, B and C must be declared and started for some representative type, such as they FUNC (10) , Call FUNC (43)) and FUNC2 (21, 6) respectively, when applicable.

A

  DEL A = () = & gt; MyClass.FUNC (10);  B  

  DL B = () => Code for  

MyClass.FUNC (43);

And, code for c

  DEL C = (= =) MyClass.FUNC2 (21, 6);   ,  b  and  c  all types of   

P>

You can also express it as:

  DEL A = new DEL (() => MyClass.FUNC (10));  

or

  DEL A = new DEL (colfenced wiley 10); Public Flexible CallFUNCWithValue10 () {MyClass.FUNC (10); }  

or simply

  DEL A = callfinsevatv10;  

No comments:

Post a Comment