gpt4 book ai didi

c# - 反射中 IEnumerable 的问题

转载 作者:行者123 更新时间:2023-11-30 19:32:07 25 4
gpt4 key购买 nike

<分区>

Possible Duplicates:
How to iterate the List in Reflection
Problem with IEnumerable in Reflection

你好,

我在反射中迭代列表时遇到问题。

var item = property.GetValue(obj,null); // We dont know the type of obj as it is in Reflection.

foreach(var value in (item as IEnumerable))
{
//Do stuff
}

如果我这样做,我会得到这样的错误

使用泛型类型“System.Collections.Generic.IEnumerable”需要 1 个类型参数

请帮帮我。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com