This is a delegate type, i.e. this is a property and it can be set. And it can be called as method.
for example
/* Action<String> is a delegate, get it as an object*/
public void Foo (String[] arr, Action<String> instruction) {
foreach (var element in arr) {
//use it as a method
instruction(element);
}
}
EDIT
The same applies to Func
// Func<Int32, Boolean> means that this is a function which accepts one argument as an integer and returns boolean.
public void Foo(Int32 data, Int32 otherData, Func<Int32, Boolean> instruction) {
var result1 = instruction(data);
var result2 = instruction(data2);
Console.WriteLine(result1==result2);
}
EDIT
Even more comprehensive example.
//This methods accepts the third parameter as a function with 2 input arguments of type
// Int32 and return type String
public static void DoSomething(Int32 data1, Int32 data2, Func<Int32, Int32, String> whatToDo) {
var result = whatToDo(data1, data2);
Console.WriteLine(result);
}
public static Main(String[] args) {
// here we are calling the DoSomething and
// passing the Concat method as if it was an object.
DoSomething(1, 2, Concat);
// The same with multiply concat.
DoSomething(7, 2, MultiplyConcat);
}
public static String Concat(Int32 arg1, Int32 arg2) {
return arg1.ToString() + " " + arg2.ToString():
}
public static String MultiplyConcat(Int32 arg1, Int32 arg2) {
return (arg1 * arg2).ToString();
}