c# - Ambiguous call between (Func<IInterface>) and (Func<Task<IInterface>>) -


why ambiguous call error between (func<iinterface>) , (func<task<iinterface>>) next code sample? , how can avoid error without replacing method group call?

public class program {     public static void main(string[] args)     {         method(getobject);     }      public static iinterface getobject() => null;      public static void method(func<iinterface> func) =>          console.writeline("first");      public static void method(func<task<iinterface>> funcasync) =>          console.writeline("second");  }   public interface iinterface { } 

this fix issue method expects function returns iinterface

public class program {     public static void main(string[] args)     {         method(() => getobject());     }      public static iinterface getobject() => null;      public static void method(func<iinterface> func) =>         console.writeline("first");      public static void method(func<task<iinterface>> funcasync) =>         console.writeline("second"); }  public interface iinterface { } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -