In Visual Studio when debugging C# code, can I export a List or a Dictionary in xml,csv or text format easily?

后端 未结 4 1345
执笔经年
执笔经年 2021-01-17 07:19

In Visual Studio when debugging C# code, can I export a Dictionary in xml,csv or text format easily?

I would like to export a

4条回答
  •  清酒与你
    2021-01-17 08:15

    Dictionary implements IEnumerable>. For debugging purposes, you can convert dictionary to multiline string using LINQ query:

    string description =
        string.Join(Environment.NewLine,
            dict.Select(tuple => $"{tuple.Key} => {tuple.Value}").ToArray());
    

    Maybe this will be enough for debugging.

提交回复
热议问题