【发布时间】:2023-03-25 01:50:01
【问题描述】:
我有一个代表:
delegate ResultType Caller<ResultType>(IPtxLogic logic);
这是一个函数:
private ResultType ExecuteLogicMethod2<ResultType>(string sessionId,
Caller<ResultType> action)
where ResultType : IResult, new()
{...}
我想用这样的东西替换函数签名:
private ResultType ExecuteLogicMethod2<ResultType>(string sessionId,
Action<IPtxLogic, ResultType> action)
where ResultType : IResult, new()
{...}
编译器告诉我:
使用泛型类型“System.Action”需要“1”类型参数
为什么?如何访问“标准”.NET 类?
谢谢。欢迎任何想法。
附:我已经创建了自定义委托来解决问题,但是......我不想为我的每个“自定义操作”创建自定义委托......
delegate ResultType Action<ParameterType, ResultType>(ParameterType param);
附言我正在使用 .NET 3.5
【问题讨论】: