【发布时间】:2017-05-24 22:33:16
【问题描述】:
我想调用这个方法:
public IEnumerable<TEntity> SelectAll(params string[] entitiesToLoad)
但在大多数情况下,我不会加载关系实体,所以我想在不发送entitiesToLoad 值的情况下调用它,如下所示:
var dbResult = methodInfo.Invoke(repository, null);
但是会抛出异常,因为参数个数不相等。
有没有办法在不将参数 string[] 更改为另一种类型的参数的情况下执行此操作?
我试过string entitiesToLoad = null as parameter,我得到了同样的错误。
【问题讨论】:
-
传递空字符串数组
-
你为什么不直接通过
new string[0]? -
new string[0] 抛出同样的错误
标签: c# system.reflection