In the BLL class, I have written:
Private List<T> GetData(string a, string b)
{
TryAction(()=>{
//Call BLL Method to retrieve the list of BO.
return BLLInstance.GetAllList(a,b);
});
}
In the BLL Base Class, I have a method:
protected void TryAction(Action action)
{
try
{
action();
}
catch(Exception e)
{
// write exception to output (Response.Write(str))
}
}
How can I use TryAction() method with generic return type?
please have a suggestion.
You need to use Func to represent a method which will return a value.
Below is an example