确定是否一个参数使用" PARAMS"使用反射在C#中? [英] Determining if a parameter uses "params" using reflection in C#?

查看:216
本文介绍了确定是否一个参数使用" PARAMS"使用反射在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑一下这个方法的签名:

Consider this method signature:

public static void WriteLine(string input, params object[] myObjects)
{
    // Do stuff.
}

我如何能够确定WriteLine方法的myObjectspararameter使用params关键字,可以采取可变参数?

How can I determine that the WriteLine method's "myObjects" pararameter uses the params keyword and can take variable arguments?

推荐答案

检查就可以了存在 [ParamArrayAttribute]

PARAMS 永远是最后一个参数的参数。

The parameter with params will always be the last parameter.

这篇关于确定是否一个参数使用" PARAMS"使用反射在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆