我是func的新手,我在Func下面定义了类似的东西,
private Func<int, Type, GridCell> getGridCell;
public Func<int, Type, GridCell> GetGridCell
{
get
{
return getGridCell;
}
set
{
getGridCell = value;
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何获得GridCell的TResult.你能就此提出建议吗?
在Func你打电话之前,A 没有结果.所以GetGridCell没有类型的值GridCell- 它是一个可以被调用来获取a 的函数GridCell.例如:
Func<int, Type, GridCell> function = GetGridCell;
GridCell cell1 = function(1, typeof(string));
GridCell cell2 = function(10, typeof(DateTime));
Run Code Online (Sandbox Code Playgroud)
究竟是怎么计算取决于它的值GetGridCell- 它可以做任何事情,基本上,因为它只是一个函数.
请注意,这不是特定于Func类型的 - 它是委托的一般概念.
| 归档时间: |
|
| 查看次数: |
113 次 |
| 最近记录: |