Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Action<> with Func<> parameter

Tags:

c#

action

func

I have the following method that I can't figure out correct syntax to call:

public T GetAndProcessDependants<C>(Func<object> aquire, 
    Action<IEnumerable<C>, Func<C, object>> dependencyAction) {}

I'm trying to call it like this:

var obj = MyClass.GetAndProcessDependants<int>(() => DateTime.Now, 
    (() => someList, (id) => { return DoSomething(x); }) }

Edited: thx everyone, you guys helped turned on a light bulb in my head. here is what i did:

var obj = MyClass.GetAndProcessDependants<int>(
            () => DateTime.Now,
            (list, f) => 
            {
                list = someList;
                f = id => { return DoSomething(id); };
            });

not sure why i even an issue with this. it's one of those days i guess..

thx

like image 503
emer Avatar asked Nov 14 '11 18:11

emer


1 Answers

Your lambda syntax is totally wrong.

You need to create a single lambda expression with two parameters:

(list, id) => DoSomething(...)
like image 118
SLaks Avatar answered Sep 24 '22 17:09

SLaks