问题描述
cGetComponents.cs
public class cGetComponents
{
public IEnumerable<Component> EnumerateComponents(object formobj)
{
return from field in GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
where typeof(Component).IsAssignableFrom(field.FieldType)
let component = (Component)field.GetValue(formobj)
where component != null
select component;
}
}
Form1.cs
cGetComponentsobj = new cGetComponents();
IEnumerable<Component> c = obj.EnumerateComponents(this);
为什么c为空,没有结果?如果我将函数EnumerateComponents()放在Form1内,则c有一些元素。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)