lambda - C#: Convert a generic function to a Func object -
i have following function:
private int getenumtypeunderlyingid<t>() { return (int)enum.parse(typeof(t), enum.getname(typeof(t), _franchise.logondialog)); } i want convert func type. write like:
func<int> getenumtypeunderlyingidfunc<t> = () => (int)enum.parse(typeof(t), enum.getname(typeof(t), _franchise.logondialog)); but not work. not comfortable when working func<>, generics , lambda expressions appreciated
you can define own delegate. here looking for:
//your function type delegate int getenumtypeunderlyingidfunc<t>(); //an instance of function type getenumtypeunderlyingidfunc<int> myfunction = () => //some code return int ; also works too.
//an instance of func delegate func<int> getenumtypeunderlyingidfunc = () => //some code return int;
Comments
Post a Comment