I am new to func, I have define the Func
like below,
private Func<int, Type, GridCell> getGridCell;
public Func<int, Type, GridCell> GetGridCell
{
get
{
return getGridCell;
}
set
{
getGridCell = value;
}
}
And I don't know how to get the TResult that is GridCell. Could you please suggest on this?
A Func
doesn't have a result until you call it. So GetGridCell
doesn't have a value of type GridCell
- it's a function which can be called to get a GridCell
. For example:
Func<int, Type, GridCell> function = GetGridCell;
GridCell cell1 = function(1, typeof(string));
GridCell cell2 = function(10, typeof(DateTime));
How exactly that is computed depends on the value of GetGridCell
- it could do anything, basically, because it's just a function.
Note that this isn't specific to Func
types - it's the general idea of delegates.
See more on this question at Stackoverflow