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
Post a Comment