一种方法,以漂亮的打印一个C#对象 [英] A way to pretty print a C# object
本文介绍了一种方法,以漂亮的打印一个C#对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文本框,我想在人类可读的方式来显示它在C#的对象,只是为了调试的原因。我不希望尽可能使用外部库。我该怎么做呢?
I have a text box and I want to display a C# object in it in a human-readable way, just for debugging reasons. I don't want to use external libraries if possible. How do I do this?
推荐答案
它序列化到JSON。它可以在的ToString()
与其他人一样的方法建议做,但我不认为这是合适的,如果你要使用,只用于调试。
Serialize it to JSON. It can be done in the ToString()
method like others suggested, but I don't think that is appropriate if you are going to use that for debugging only.
这篇关于一种方法,以漂亮的打印一个C#对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文