首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >递归函数中的asp网络参数计数不匹配

递归函数中的asp网络参数计数不匹配
EN

Stack Overflow用户
提问于 2019-06-26 04:35:36
回答 1查看 162关注 0票数 0

我的一个函数出了点小问题。当我对递归部分进行注释时,我在DropDownList中得到了4个项目。但是,当我取消对递归部分的注释时,我得到错误消息“参数计数不匹配”。

我查看了一些函数,但到目前为止什么也没有找到。该函数接受第一个对象,它是一个格式化的JSON数据。然后,它应该给我类中每个属性的值。

编辑:我按照发布的示例(Parameter Count Mismatch exception when calling PropertyInfo.GetValue)做了,但现在我得到错误"System.Reflection.RuntimeParameterInfo‘无法转换为类型’System.Int32‘“有什么想法吗?我还编辑了代码:

代码语言:javascript
复制
     protected void wystaw_liste(object obj)
    {
        if (obj == null) return;
        Type type = obj.GetType();
        PropertyInfo[] properties = type.GetProperties();

        foreach (PropertyInfo property in properties)
        {
            object propValue = new object();
            ParameterInfo[] index = property.GetIndexParameters();
            if (index.Count() == 0)
            {
                propValue = property.GetValue(obj, null);
            }
            else
            {
                    propValue = property.GetValue(obj, index);
            }
            var elems = propValue as IList;
            if (elems != null)
            {
                foreach (var item in elems)
                {
                    wystaw_liste(item);
                }
            }
            else
            {
                if (property.PropertyType.Assembly != type.Assembly)
                {
                    if (propValue != null)
                    {
                        parametry_list.Add(propValue.ToString());
                    }
                }
            }
        }
    }

你知道怎么解决这个问题吗?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56761661

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档