Is there any way to pass the lambda expression as a variable or argument?

后端 未结 5 1251
-上瘾入骨i
-上瘾入骨i 2021-02-19 07:10

I need to pass the lambda query as a parameter, the followings code is sample and I am interesting to find an implement for it, there is samples: some thing like this:

5条回答
  •  自闭症患者
    2021-02-19 07:47

    Well, a lambda is nothing but a delegate, so you could have a method like this:

    public void DoIt(IEnumerable a, Action performThis)
    {
      performThis(a);
    }
    

    But where's the sense in it? Instead of calling a method that applies your lambda, why not calling it directly as you do in the last lines of your code?

提交回复
热议问题