如何在Linqpad中的IEnumerable上转储正常属性 [英] How can I dump the normal properties on an IEnumerable in Linqpad

查看:73
本文介绍了如何在Linqpad中的IEnumerable上转储正常属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个对象,其中包括IEnumerable,然后转储该对象,我将获得枚举值.

If I have an object that among other things is an IEnumerable and I dump this object I get the enumerated values.

有没有办法让Linqpad列出其他属性:

Is there a way to get Linqpad to list the other properties:

下面的例子: 我可以让Dump包含Hello和digits属性吗?

Se example below: Can I get Dump to include Hello and digits properties?

void Main()
{
    var t = new test();
    var d = new Dictionary<string,string> {{"Hello","World"},{"Good by","Sky"}};

    t.Dump();
    d.Dump();
}

// Define other methods and classes here

public class test : IEnumerable
{
    public string Hello { get { return "World"; }}
    public List<int> digits { get { return new List<int> {0,1,2,3,4,5,6,7,8,9}; }}

    public IEnumerator GetEnumerator() { yield return "Hej"; }
}

推荐答案

据我所知,您要转储的对象是否实现IEnumerable,那么LINQPad始终希望将其转储为IEnumerable列表.正确删除界面会在转储的信息中显示Hellodigits属性.

As far as I can tell if the object you're trying to dump implements IEnumerable then LINQPad always wants to dump it as an IEnumerable list. Getting rid of the interface correctly shows the Hello and digits properties in the dumped info.

此链接开始,看来您可以编写自己的转储,通过枚举集合的所有属性,然后将整个内容输出为XHTML字符串.我没有尝试过.

Going from this link it appears you can write your own dump which accomplishes something like LINQPad by enumerating the collection and all it's properties then outputting the whole thing as an XHTML string. I haven't tried this.

这篇关于如何在Linqpad中的IEnumerable上转储正常属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆