I'm trying to pass a Func<TResponse, T1, T2>
through to this method. I keep getting a syntax error for "method()" though. It says it needs two arguments which makes sense, but how do I pass it to the method? I've assigned them as T1 and T2.
How can I make this return the TResponse as well?
The way I'm calling it (the func I want to use to call the method).
_service.Count(fileDate (DateTime), cycle int));
What am I doing wrong here?
public TResponse ExecuteAndLog<T1, T2,TResponse>(Guid id, string Name, Func<T1, T2, TResponse> method) where TResponse : class
{
try
{
Log(id, Name);
TResponse x = method();
Log(id, Name);
}
catch (Exception ex)
{
Log(id, Name);
throw;
}
}