gpt4 book ai didi

c# - property.GetValue() 中的参数计数不匹配

转载 作者:IT王子 更新时间:2023-10-29 04:52:44 24 4
gpt4 key购买 nike

<分区>

我得到了

parameter count mismatch

错误。它出现在 if 子句中。我的代码:

private Dictionary<string,string> ObjectToDict(Dictionary<string, string> dict, object obj)
{
var properties = obj.GetType().GetProperties();
foreach (var property in properties)
{
if (property.GetValue(obj, null) != null)
dict["{{" + property.Name + "}}"] = property.GetValue(obj, null).ToString();
}
return dict;
}

这很奇怪,因为当我将 property 值添加到字典时它工作得很好,但当我在 if 中测试它是否为 null 时却不行 子句。

我发现的所有问题都是在函数调用中输入了错误数量的参数,但据我所知,我的两次调用之间没有什么不同。

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