草庐IT

ExecuteMethod

全部标签

c# - 我可以通过反射/诊断从方法中获取调用实例吗?

有没有办法通过System.Reflection、System.Diagnostics或其他方式获取对调用静态方法的实际实例的引用,而不将其传递给方法本身?例如,沿着这些线的东西classA{publicvoidDoSomething(){StaticClass.ExecuteMethod();}}classB{publicvoidDoSomething(){SomeOtherClass.ExecuteMethod();}}publicclassSomeOtherClass{publicstaticvoidExecuteMethod(){//ReturnsaninstanceofAif