Determining if a parameter uses “params” using reflection in C#?

前端 未结 3 496
时光取名叫无心
时光取名叫无心 2021-01-17 07:47

Consider this method signature:

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

How can I determ

3条回答
  •  一生所求
    2021-01-17 08:14

    A slightly shorter and more readable way:

    static bool IsParams(ParameterInfo param)
    {
        return param.IsDefined(typeof(ParamArrayAttribute), false);
    }
    

提交回复
热议问题