问个反射的问题
public class Abc{
public string UserName="";
public void a(){
this.UserName = "What the fucking chinese english!";
}
public void Set(){
foreach(var item in typeof(Abc).GetMethods()){
if(item.Name == "a"){
item.Invoke(this,null);
}
}
}
}
实例化这个Abc对象之后
调用Set方法 之后为什么UserName的值不改变啊
[解决办法]
首先,信息不足。把你的执行代码发出来看看
其次
我不太理解你这样做的意义。。
明明Set方法已经是Abc对象的内部方法了。
他是可以知道a方法的存在的。。为什么要这样多此一举的用反射来拉低运行效率。