What is the advantage of Currying in C#? (achieving partial function)

后端 未结 5 2073
情深已故
情深已故 2021-02-07 09:13

What is the advantage of Currying in C#?

What is the advantage of achieving partial function application on a curried function?

5条回答
  •  难免孤独
    2021-02-07 09:57

    If your question was how to implement currying in C# , here is an example

    public Func> Curry(Func func)
        {
            return p1 => p2 => func(p1, p2);
        }
    

    Currying can be implemented in any language that supports closures(lambdas), and is useful for partial function application like in UI programming where all the input necessary for the execution of function isnt received, so a curried function is passed around with already received inputs captured in it.

提交回复
热议问题