小编use*_*501的帖子

C#反射不适用于Point类?

我无法弄清楚我做错了什么.我有这个代码:

Point p = new Point();
//point is (0,0)
p.X = 50;
//point is (50,0)
PropertyInfo temp = p.GetType().GetProperty("X");
temp.SetValue(p, 100, null);
//and point is still (50,0)
MethodInfo tt = temp.GetSetMethod();
tt.Invoke(p, new object[] { 200 });
//still (50,0)
Run Code Online (Sandbox Code Playgroud)

为什么?

我在寻找答案,但我什么也没找到.

c# reflection properties point

2
推荐指数
1
解决办法
153
查看次数

标签 统计

c# ×1

point ×1

properties ×1

reflection ×1