List<T>.ForEach Method (Action<T>) how to pass action to it

excel
uiautomation
activities

#1

hi,
I am trying to compare list with string using Contains String element… In input: list.foreach(delegate(MailMessage)) and In search: string
But In input it is showing error as ‘)’ Expected…


#2

I’m not sure if I understand the question…

Could you elaborate on what is the input and expected output? From the description I don’t see a reason to use a .ForEach here.
Do note that .ForEach(Action<T>) is for invoking a (usually anonymous) void method on each of the elements and is a syntax equivalent of:
foreach (T item in List<T>) myVoidMethod(item);

If the Action you want to pass is not very simple, I’d suggest to either make an activity for it or use a normal ForEach loop and do it in it’s body.

Regards.