Can you get a list of variables on the stack in C#?

给你一囗甜甜゛ 提交于 2019-12-21 02:56:08

问题


All, just wondering if it's possible in .NET/C# to get a list of variables on the stack and their values? I am creating an exception handler for my app and beyond a standard stack trace I'd also like to see the names and values for any variables that are on the stack. Any idea if this can be done?


回答1:


Yes, the StackFrame class can help you with that.

Linkage

Something along these lines

var currentStackFrame = new StackFrame(1);
var props = currentStackFrame.GetMethod().GetParameters(); 


来源:https://stackoverflow.com/questions/376256/can-you-get-a-list-of-variables-on-the-stack-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!