You would do something like
add.ForEach(_obj =>
{
_uow.Questions.Add(_obj);
Console.WriteLine("TADA");
});
Have a look at the examples in Action Delegate
The following example demonstrates the use of the Action delegate
to print the contents of a List object. In this example, the Print
method is used to display the contents of the list to the console. In
addition, the C# example also demonstrates the use of anonymous
methods to display the contents to the console. Note that the example
does not explicitly declare an Action variable. Instead, it passes
a reference to a method that takes a single parameter and that does
not return a value to the List.ForEach method, whose single
parameter is an Action delegate. Similarly, in the C# example, an
Action delegate is not explicitly instantiated because the
signature of the anonymous method matches the signature of the
Action delegate that is expected by the List.ForEach method.
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
List<String> names = new List<String>();
names.Add("Bruce");
names.Add("Alfred");
names.Add("Tim");
names.Add("Richard");
// Display the contents of the list using the Print method.
names.ForEach(Print);
// The following demonstrates the anonymous method feature of C#
// to display the contents of the list to the console.
names.ForEach(delegate(String name)
{
Console.WriteLine(name);
});
names.ForEach(name =>
{
Console.WriteLine(name);
});
}
private static void Print(string s)
{
Console.WriteLine(s);
}
}
/* This code will produce output similar to the following:
* Bruce
* Alfred
* Tim
* Richard
* Bruce
* Alfred
* Tim
* Richard
*/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…