I'm having problems getting my head around Action delegates in C#
I've looked at this question and I understand the examples there, but in the codebase that I'm working on it's used in a way that I don't quite get. This is the method using the action delegate:
public static string RenderTemplate<T>(string templatePath, T data)
{
string result = null;
ExecuteRazorMethod(() =>
{
result = Razor.Run(data, templatePath);
});
return result;
}
The call to ExecuteRazorMethod() will invoke the following method:
private static void ExecuteRazorMethod(Action a)
{
try
{
a();
}
.
.
.//irrelevant code
.
}
I don't understand what happens when a() is executed. What method is invoked? I've tried debugging it, and the value of a passed into the method is : Void <RenderTemplate> b__5
I don't get that. I need to know what actually happens to the two parametes in RenderTemplate but not understanding what/where the a()
executes makes it hard. Is it maybe something about Anonymous types that I don't understand?