Fabulous Adventures In Coding

Ayende在使用.Net 3.0的时候遇到了这样一个问题Csc.exe and delegate inference, or: Why C# has awkward syntax

public   class  TestCsc
{
public   static   void  TestMethod()
{
Execute(Bar); 
//  fail to compile
            Execute( delegate ( int  ia,  string  x) { });  //  compiles fine
            Execute(( int  i,  string  x)  =>  {  return ; });  //  Compiles fine
            Execute(( int  i,  string  x)  =>  {  return   true ; });  //  fail to compile
            Execute(Foo); //  fail to compile
            Execute( delegate ( int  ia,  string  x) {  return   true ; });  //  fail to compile
        } 

public   static   bool  Foo( int  ia,  string  x)
{
return   false ;


public   static   void  Bar( int  ia,  string  x)
{


public   static   void  Execute < T, K > (Action < T, K >  e)
{


public   static   void  Execute < T, K > (Func < bool , T, K >  e)


}


 

失败的原因是什么呢??

Eric Lippert在他的blogFabulous Adventures In Coding 中给出了他的解释.

 

你可能感兴趣的:(Fabulous Adventures In Coding)