I get
mismatch in the number of parameters
error. This happens in the if clause. My code is:
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; }
This is strange because it works fine when I add the property value to the dictionary, but not when I test if it is null in the if clause.
All the questions I found put the wrong number of arguments in a function call, but AFAIK there is nothing different between my two calls.
source share