什么是转储整个对象到一个日志在C#中的最佳方式? [英] What is the best way to dump entire objects to a log in C#?
本文介绍了什么是转储整个对象到一个日志在C#中的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,对于在运行时查看当前对象的状态,我真的很喜欢在Visual Studio即时窗口给我。只是做一个简单的
So for viewing a current object's state at runtime, I really like what the Visual Studio Immediate window gives me. Just doing a simple
? objectname
会给我对象的一个很好的格式化的垃圾。
Will give me a nicely formatted 'dump' of the object.
有没有一种简单的方法在code要做到这一点,所以我可以做类似的东西登录时?
推荐答案
您可以立足于ObjectDumper code附带的的 Linq的样品的。结果
也有看看这个的答案相关问题获得样本。
You could base something on the ObjectDumper code that ships with the Linq samples.
Have also a look at the answer of this related question to get a sample.
这篇关于什么是转储整个对象到一个日志在C#中的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文