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