.net 一个委托声明能否继承另一个委托声明?

.net 一个委托声明能否继承另一个委托声明?,.net,generics,.net-4.0,delegates,.net,Generics,.net 4.0,Delegates,有没有一种方法可以让我在不再次键入整个签名的情况下写出以下内容 //desired base signature public delegate string BaseDelegate<TProfile, TResult>(string requestorID, DateTime sentDate, string serviceID, string source, TProfile profile, out DateTime recieved, out Dat

有没有一种方法可以让我在不再次键入整个签名的情况下写出以下内容

//desired base signature
    public delegate string BaseDelegate<TProfile, TResult>(string requestorID, DateTime sentDate, string serviceID,
        string source, TProfile profile, out DateTime recieved, out DateTime sent, out string psatSystemID, out TResult[] result);

//ugly version of child
public delegate string CurriedDelegate<T>(string requestorId, DateTime sentDate, string serviceId, string source,
T profile, out DateTime recieved, out DateTime sent, out string psatSystemID, out T[] result);

//syntax sugar,doesn't compile
    public BaseDelegate<T,T> CurriedDelegate<T>; //TProfile is same type as TResult
//所需的基本签名
公共委托字符串BaseDelegate(字符串请求者ID、日期时间sentDate、字符串服务ID、,
字符串源、TProfile配置文件、接收的out DateTime、发送的out DateTime、输出的字符串psatSystemID、输出的TResult[]结果);
//丑陋的孩子
公共委托字符串CurriedDelegate(字符串请求者ID、日期时间sentDate、字符串服务ID、字符串源、,
T profile,out DateTime received,out DateTime sent,out string psatSystemID,out T[]result);
//语法糖,不编译
公共基础代表(CurriedDelegate)//TProfile与TResult的类型相同

不,虽然如果两个类型参数相同,您可以从
BaseDelegate
创建
CurriedDelegate
,但是没有办法做到这一点

在我看来,更好的解决方案是将各种参数封装在一个单独的类型中。这真的是一个可怕的长签名开始,大概参数是相互关联的


(我也会尽量避免使用太多的
out
参数-也许您实际上有两种类型要封装在这里,一种用于输入,一种用于输出?

不,没有办法做到这一点,尽管如果两个类型参数相同,您可以从
BaseDelegate
创建
CurriedDelegate

在我看来,更好的解决方案是将各种参数封装在一个单独的类型中。这真的是一个可怕的长签名开始,大概参数是相互关联的


(我也会尽量避免使用太多的
out
参数-也许你实际上有两种类型要封装在这里,一种用于输入,一种用于输出?

是的,我调用的代码在项目的这个阶段超出了清理范围。据我所知,在大多数情况下,98%的服务层甚至使用了2个参数。当你说我可以创建一个
CurriedDelegate
,你的意思是实例化,而不是定义一个短/甜类型签名,对吗?在>80%的服务层中,代码
t配置文件
TResult
是相同的。@马斯洛:是的,如果您已经有了
BaseDelegate
,您可以使用
new CurriedDelegate(existingDelegate)
。是的,我调用的代码在项目的这个阶段不在清理范围之内。据我所知,在大多数情况下,98%的服务层甚至使用了2个参数。当你说我可以创建一个
CurriedDelegate
,你的意思是实例化,而不是定义一个短/甜类型签名,对吗?在>80%的服务层中,代码
t配置文件
TResult
是相同的。@马斯洛:是的,如果您已经有了
BaseDelegate
,您可以使用
new CurriedDelegate(existingDelegate)