非泛型类型 'System.Collections.ArrayList' 不能与类型参数一起使用

The non-generic type 'System.Collections.ArrayList' cannot be used with type arguments

我通过反射读取了一个私有字段:

var parameters = typeof(HqlProvider).GetField("paramList", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(query);

而且效果很好。我可以放入断点并查看所有内容。但是当我尝试将参数转换为它是什么(ArrayList)时,我得到 The non-generic type 'System.Collections.ArrayList' cannot be used with type arguments.

它怎么能不把它转换成它本来的样子呢?

ArrayList 不是通用的并且没有实现通用接口,因此您需要转换为非通用版本,例如

var al = (ArrayList)parameters
var l = (System.Collections.IList)parameters