1

I have a function FUNC1(int a) and a function FUNC2(int a, int b). I have a delegate with a type of void() (no arguments). I want to have 2 variables. When I call one like this: VAR1() then FUNC1(4) will run. and VAR2 that will run FUNC2(2,9). I asked this yesterday, and I was told to use anonymous methods like this: VAR1 = () => FUNC1(4) and it works fine.

Now I want to do something a little more complicated. I have a new type of delegate void(int a). and I want a variable VAR3. When I call VAR3(5) I want to execute FUNC2(5,8). If I call VAR3(9) I want to execute FUNC2(9,8). So basically, the first argument can change, but the second argument is constant.

Amy B
  • 108,202
  • 21
  • 135
  • 185
RexMan85
  • 59
  • 1
  • 1
  • 6
  • Sounds like you need `VAR3 = (i)=> FUNC2(i, 8);` Btw your question is hard to understand. Adding some code will make it better. – Sriram Sakthivel Mar 18 '15 at 07:27
  • I think you should learn the basics about how to use delegates and anonymous methods. You could start here: http://www.codeproject.com/Articles/47887/C-Delegates-Anonymous-Methods-and-Lambda-Expressio – DerApe Mar 18 '15 at 07:35

1 Answers1

1

Well, that woulde be something like that:

VAR3 = (x)=>FUNC2(x,8);
Udontknow
  • 1,472
  • 12
  • 32