Convert Method Group to Expression

后端 未结 3 1795
情深已故
情深已故 2021-01-17 16:00

I\'m trying to figure out of if there is a simple syntax for converting a Method Group to an expression. It seems easy enough with lambdas, but it doesn\'t translate to meth

3条回答
  •  孤街浪徒
    2021-01-17 16:30

    It is also possible to do it using NJection.LambdaConverter a Delegate to LambdaExpression converter Library

    public class Program
    {
        private static void Main(string[] args) {
           var lambda = Lambda.TransformMethodTo>()
                              .From(() => Parse)
                              .ToLambda();            
        }   
    
        public static int Parse(string value) {
           return int.Parse(value)
        } 
    }
    

提交回复
热议问题