내가 올바르게 원하는 것을 설명하는 방법을 모르겠습니다. 여기에 예제^다른 방법의 변수에 액세스하는 방법
public void foo()
{
StackFrame trace = new StackFrame(1);
MethodBase method = trace.GetMethod(); //so, here we'll get bar-method info
MthodBody body = method.GetMethodBody(); //and here we'll get bar-method body
/*now i need get access to the local vars in bar
i know about MethodBody.LocalVariables
but i don't have any idea how i can get values of variables i and hello,
that defined in bar-method. I think it may be possible if i'll get
pointers to the vars,
and then copy it with Marshal.Copy*/
}
public void bar()
{
int i = 42;
string hello = "Hello!";
foo();
}
PS 내 예 끔찍한 아니었다 희망, 당신은 정확하게 내가 원하는 것을 이해합니다. PPS 내 나쁜 나쁜 나쁜 영어 :
달성하고자하는 것은 무엇입니까? 네가 올바른 방향으로 가고 있는지 나는 모른다. – empi
다음과 같이 문자열 형식 작성기를 간단하게 작성해보십시오. int i = 24; 형식 ("i = {i}"); // will write i = 42 –
'LocalVariableInfo' 인스턴스에서 값을 가져올 수 없습니다. –