use*_*375 30 .net c# reflection
我试图得到一个窗口的值如下
这指的是主窗口(window1)
Type type = this.GetType();
PropertyInfo pi = type.GetProperty("Left");
object obj = pi.GetValue(type, null);
Run Code Online (Sandbox Code Playgroud)
但我得到一个"对象与目标类型不匹配使用"错误.怎么了?
Sky*_*ers 50
因为您试图获取Type的"Left"属性,而不是您的实例.
试试这个
object obj = pi.GetValue(this, null);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27772 次 |
| 最近记录: |