c# - How can I use System.Func? -


i have trouble using system.func.

public func<int> oncreated=new func<int>(int asd){ debug.log (asd); }; 

is proper way use it? want make dynamic function can called. can system.func serialized via xml?

maybe you're looking action<> instead?

action<int> myaction = myintparam => debug.log(myintparam); myaction(myinteger); 

if want take input parameter, , return something, should use func<>

func<int, int> myfunc = myintparam => {    debug.log(myintparam);    return 5; }; int 5 = myfunc(myinteger); 

also, if want serialize/deserialize, need take 1 step further. namely, def func not have meaningful information serialized, should wrap in expression. can started googling "c# serialize expression", eg: https://expressiontree.codeplex.com


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -