The Immediate Window: Implicit Variables

Tips Search

If you like the tips then you'll love the book!

Order your copy today:
http://www.amazon.com/gp/product/0735649928

The Immediate Window: Implicit Variables

  • Comments 3

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

  • 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.

  • x = 0

    ? int32.TryParse("no", x)

    works like a charm.

  • :)

Page 1 of 1 (3 items)
Leave a Comment
  • Please add 5 and 3 and type the answer here:
  • Post