Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        4年前关闭。
                                                                                            
                
        
有没有办法知道该函数是否是MethodInfo编制的Expression?

最佳答案

扩展我的评论并进一步@SLAks回答...

表达强壮的成员只是语法糖,它们编译为相同的代码。例如,考虑此类:

public class Blah
{
    public void Foo() { Console.WriteLine("Hello"); }
    public void Bar() => Console.WriteLine("Hello");
}


生成的IL如下所示,除了nop(在调试模式下进行编译的副作用)之外,它们是相同的:

Blah.Foo:
IL_0000:  nop
IL_0001:  ldstr       "Hello"
IL_0006:  call        System.Console.WriteLine
IL_000B:  nop
IL_000C:  ret

Blah.Bar:
IL_0000:  ldstr       "Hello"
IL_0005:  call        System.Console.WriteLine
IL_000A:  nop
IL_000B:  ret

关于c# - 有没有办法知道方法是否是MethodInfo的表达式主体成员,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33417778/

10-13 08:43