Parameter Count Mismatch exception when calling PropertyInfo.GetValue

后端 未结 3 495
谎友^
谎友^ 2020-12-11 15:06

I\'m trying to compare two objects at runtime using reflection to loop through their properties using the following method:

         


        
3条回答
  •  鱼传尺愫
    2020-12-11 15:10

    for C#:

    PropertyInfo property = .....
    ParameterInfo[] ps  = property.GetIndexParameters();
    if (ps.Count() > 0)
    {
      if(obj.ToString().Contains("+"))
      {
          Debug.Write("object is multi-type");
      }
      else { 
        var propValue = property.GetValue(obj, null);
        ....
      }
    }
    

提交回复
热议问题