Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I declare new variables in the immediate window?

This could save me so much time. Sometimes I find myself writing things like this in the watch or immediate window:

MyObject.Function1.Fuction2.Fuction3.Fuction2 

Instead I could just declare several new variables and do this in a more structured way.

However doing this is not allowed.

Is there some way that i can do this? Is there going to be support for what I want in any future versions?

like image 906
Tomasi Avatar asked Mar 07 '10 17:03

Tomasi


People also ask

How do I enable immediate windows?

The Immediate window evaluates expressions by building and using the currently selected project. To display the Immediate window, open a project for editing, and then choose Debug > Windows > Immediate or press Ctrl+Alt+I. You can also enter Debug.

What is 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 add variables to my watch window?

Right click on the variable in code, and select "Add Watch" Right click on the variable in the "Locals" windows, and select "Add Watch" Type the variable name into a new row in the Watch pane itself.

How do I Debug an immediate window?

The immediate window can be displayed in several ways. One is to open the "Debug" menu and the "Windows" submenu then select "Immediate". In some configurations of Visual Studio this menu option may not be present. In this case, you can press Ctrl-Alt-I, or Ctrl-D,I in Visual Studio 2010.


2 Answers

Just answering the question from the headline:

In VS2015 you can declare variables in the immediate window. But you have to end your command with a semicolon:

var abc = "abcdef"; Expression has been evaluated and has no value 

or

var n = 7; Expression has been evaluated and has no value 

or

int o = 8; Expression has been evaluated and has no value 

To show the result, just type the name of your variable:

abc "abcdef" 

or

?abc "abcdef" 

or

?abc; "abcdef" 

or

abc; "abcdef" 
like image 74
huha Avatar answered Sep 24 '22 13:09

huha


Do not use Dim

jack = 12 ? jack 12 {Integer} 
like image 28
AMissico Avatar answered Sep 22 '22 13:09

AMissico