次の方法で共有


The Immediate Window: Implicit Variables

Keyboard:  CTRL + ALT + I
Menu:  Debug -> Windows -> Immediate
Command:  Debug.Immediate
Versions:  2008,2010
Published:  10/4/2010
Code:  vstipTool0100

 

In the Immediate Window you can create implicit variables. These implicit variables never go out of scope and can be treated as any other variable.  They are approached differently in VB and C#.

 

C#

To create an implicit variable in C# just declare any variable in the Immediate Window:

image

 

If you are in debug mode, you can actually see the variable in your Locals window.  Implicit variables will show up with a "$" in front of them:

image

 

 

 

VB

In VB, you cannot declare implicit variables in the Immediate Window. But, if you use an undeclared variable, an implicit variable is created automatically. Unfortunately, VB implicit variables are not listed in the Locals window:

image

Comments

  • Anonymous
    January 10, 2012
    Your statement about VB's immediate window is not true. Try this... ? int32.TryParse("no",x) ...and it will say that x is not declared, and it won't make a variable for you as you suggest.

  • Anonymous
    January 10, 2012
    x = 0 ? int32.TryParse("no", x) works like a charm.

  • Anonymous
    January 10, 2012
    :)