Design Time Expression Evaluation - Immediate Window

Immediate Window is a build in Visual Studio tool that people often forget about. Mostly because it shows only at debug time and usage is not obvious as watch window. The Immediate window is used at debug and design time to debug and evaluate  expressions, execute statements, print variable values, and so forth. Yes, you can use Immediate window at design time. Lets say you write a method:

private static int Sum(int a, int b)

{

   return a + b;

}

 

Then you can type in Immediate window:

 

?Sum(10,12)


 

and below would be result:

 

22

  

You can even debug, while you are in design mode. More information about debugging at design time in MSDN.


Posted on Thursday, August 14, 2008 by | Comments (4) | Add Comment

Comments

Gravatar

Re:Design Time Expression Evaluation - Immediate Window

try as i might, i cannot get vs2008 c# immediate window to do your example at design time...what am i doing wrong?

Posted on 9/29/2009 1:52:17 PM by Kevon Ward #
Gravatar

Create new console application. Copy paste my piece of code. Press Ctrl - D,I to show Immediate window. Type ?Sum(10,12) in it and hit enter. You should see result then.

Gravatar

Re:Design Time Expression Evaluation - Immediate Window

how i can see the C#.net output in immediate windows ,what is code for that in c#.net

Posted on 4/16/2010 1:38:57 AM by vishal #
Gravatar

You can't see C# output in immediate window. You can call method from immediate window and then see what this method returns. You can use Debug.Write method to write to output window, but not to immediate window.

Gravatar

Re:Design Time Expression Evaluation - Immediate Window

But you can redirect all output to immediate window by choosing this option in VS config.

Posted on 8/23/2010 11:53:42 AM by Eddie Torin #
Gravatar

Re:Design Time Expression Evaluation - Immediate Window

Here's a way to evaluate expressions at runtime:

http://www.blackbeltcoder.com/Articles/algorithms/a-c-expression-evaluator

Posted on 12/26/2010 11:10:58 AM by Jonathan Wood #

New Comment

Your Name:
Email (for internal use only):
Comment:
 
Code above:

Categories

Recent Tweets

  • Simon Ince's Blog: Hierarchies with HierarchyID in SQL 2008 http://t.co/xSDwiF6rRS.
  • Visual Studio 2010 WAS painfully slow - CodeProject http://t.co/Usba1x6CZy

Valid HTML5