Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newlines in the Immediate Window

Using Visual Studio 2010 Professional, I have a ToString() method that looks like this:

public override string ToString() {     return "something" + "\n" + "something"; } 

Because there are several "something"'s and each is long, I'd like to see

something something 

Sadly, I'm seeing

"something\nsomething" 

Is there a way to get what I want?

like image 510
Bob Kaufman Avatar asked May 19 '10 19:05

Bob Kaufman


People also ask

Which variable is viewed in the immediate window?

Use the Immediate window to debug and evaluate expressions, execute statements, and print variable values. The Immediate window evaluates expressions by building and using the currently selected project.

What is Immediate window in computer?

The Immediate window displays information resulting from debugging statements in your code or from commands typed directly into the window. To display the Immediate window. From the View menu, choose Immediate window (CTRL+G).

What is the difference between immediate window and window?

The differences between the Command and Immediate windowsThe Command window can load dlls or packages into the IDE as well. The Immediate window, on the other hand, is solely used during debugging and is useful to execute statements, print values of a contextual variable, or even evaluate expressions.

How do I use Immediate Windows?

Use the Immediate Window to Execute Commands The Immediate Window can also be used to execute commands. Just type a > followed by the command. For example >shell cmd will start a command shell (this can be useful to check what environment variables were passed to Visual Studio, for example). >


1 Answers

Actually there is a way. You can use format specifiers in the immediate window to change the format of the display. If you have a string with carriage returns and linefeeds in it ("\r\n") you can follow the print request with the 'no quotes' format specifier.

In the immediate window type:

?MyObj.ToString(),nq 

and the \r\n will cause newlines in the immediate window.

For more info on format specifiers see: http://msdn.microsoft.com/en-us/library/e514eeby.aspx

like image 127
davesem Avatar answered Sep 24 '22 15:09

davesem