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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -