使用以下代码,是否可以在MethodA()
中使用反射来找出MethodB()
中使用了哪些常量?
public class Foobar
{
protected const int TEST1 = 12;
protected const int TEST2 = 5678;
protected const int TEST3 = 83;
public void MethodA()
{
MethodInfo mi = typeof(Foobar).GetMethod("MethodB");
MethodBody mb = mi.GetMethodBody();
// At run time, how can I determine which constants where used in MethodB()?
}
public void MethodB()
{
int TestToRun = TEST2;
}
}