In Visual Studio when debugging C# code, can I export a Dictionary<string,string>
in xml,csv or text format easily?
I would like to export a Dictionary<string,string>
in excel and see 2 columns of strings.
Debugging such dict in VS is cumbersome.
If there s any add on that simplifies visualization that s ok too.
Visual Studio Code supports the following debuggers for C/C++ depending on the operating system you are using: Linux: GDB. macOS: LLDB or GDB. Windows: the Visual Studio Windows Debugger or GDB (using Cygwin or MinGW)
vscode folder. VSCode can create and auto-configure these files if we try to debug for the first time. To do that, open C++ file in VSCode and either hit F5 or go to Debug -> Start Debugging and select C++ (GDB/LLDB) then select g++.exe build and debug active file .
message, choose the Install more tools and features link. Then, in the Visual Studio Installer, choose the Desktop development with C++ workload. In the Configure your new project window, type or enter get-started-debugging in the Project name box. Then, choose Create.
C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS.
You can add a watch to your Dictionary (or List), then under the Watch Window you can then expand the entire dictionary (or List), right click, select-all, copy
Then in Excel you can paste the data and it should auto-format:
You could also just paste this data directly into another text-editor (or just view the data directly in the watch window too).
Hope that can help.
You could use a simple snippet like this:
var output = dict.Select(kv => string.Format("{0},{1}", kv.Key, kv.Value)); File.WriteAllLines("output.csv", output);
As noted in the comments, if your dictionary keys or values contain any commas or newlines, you'll need something slightly more complex to generate valid a CSV file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With