4

只需要进行一些反思,我注意到MethodInfoReturnParameter,ReturnTypeReturnTypeCustomAttributes.

现在ReturnParameter包含ReturnTypeand ReturnTypeCustomAttributes。那么不应该ReturnTypeReturnTypeCustomAttributes标记为已弃用吗?还是我在某个地方错过了某个目的。

  • ReturnParameter在 .net 2.0 中添加
  • ReturnType在 .net 1.0 中添加
  • ReturnCustomAttributes在 .net 1.0 中添加
4

1 回答 1

1

ReturnParameter 似乎是返回类型和属性的包装器。看起来它是为了某种方便而添加的:

编译器设计人员可以使用此属性返回的 ParameterInfo 对象来发现是否已将自定义修饰符(例如 IsConstModifier)应用于返回类型。

有趣的是 IsConstModifier 本身已被弃用。

所以我会继续使用 ReturnType。

(刚刚检查了当前项目使用的系统库中的使用情况。ReturnParameter 使用了 8 次,ReturnType - 超过 200 次)。

于 2013-10-04T13:53:06.863 回答