Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying the contents of a List<string> to text file while debugging

Tags:

I need to compare the contents of a List for two runs for my program. What is the easiest way to copy the entire contents of the List manually from Visual Studio to notepad while stepping through the code. I can view the contents in QuickWatch. How can I copy all the elements?

like image 473
softwarematter Avatar asked Jun 18 '11 04:06

softwarematter


People also ask

Why use breakpoints in debugging?

Breakpoints are one of the most important debugging techniques in your developer's toolbox. You set breakpoints wherever you want to pause debugger execution. For example, you may want to see the state of code variables or look at the call stack at a certain breakpoint.

How do you copy debugging?

Right click on the player, then select Copy debug info from the menu. To share the debug information, paste it from your computer.


2 Answers

You can open the immediate window and run something like:

string.Join(", ", yourList) 

or just

yourList 

To open the immediate window: Debug -> Windows -> Immediate or the equivalent Ctrl+D, I

like image 45
Petar Ivanov Avatar answered Sep 20 '22 13:09

Petar Ivanov


Simply type this into the immediate window:

 File.WriteAllLines("foo.txt", yourList); 

Or if it's a list of something other than strings:

 File.WriteAllLines("foo.txt", yourList.ConvertAll(Convert.ToString)); 
like image 162
Sven Avatar answered Sep 19 '22 13:09

Sven